In a real conversation you don't repeat yourself: after asking about someone, you ask "what about her projects?". That's easy for a person and hard for a search engine, because "her projects" on its own doesn't say whose. This page explains how LocalCortex handles follow-up questions.
The conversation the model sees
Along with the passages from your documents, the model is shown the last 6 messages of the chat (long answers are shortened to 800 characters). That's what lets it understand "her" or "that policy" when it writes the answer.
Two exceptions:
- If the search found nothing relevant, the history is left out and the model gets the plain "I couldn't find it" prompt. Otherwise an off-topic question could get an answer spun from the earlier conversation.
- Answers that were stopped halfway or failed are shown in the chat but never sent back to the model.
Step 1: does the question refer back?
Before searching, LocalCortex checks the question with a simple word check. No AI is involved, so it takes no time. A question counts as a follow-up that needs rewriting if:
- it contains a referring word: he, him, his, she, her, hers, they, them, their, it, its, this, that, these, those, one, ones, there, same, former, latter
- or it starts with And…, Also…, So…, What about…, How about…
| Question | Referring word? | What happens |
|---|---|---|
| Tell me more about her. | yes | sent to the model to be rewritten |
| What about the second project? | yes | sent to the model to be rewritten |
| And after five years? | yes | sent to the model to be rewritten |
| Can I carry over what I don't use? | no | searched together with the previous question (step 3) |
| What is the capital of France? | no | never sent to the rewriter |
The first question in a chat is always searched as it is. There's nothing earlier for it to refer to.
Step 2: rewrite it into a standalone question
A question that refers back is given to llama3,
along with the recent conversation, and turned into a question
that makes sense on its own:
You: Who is ABC?
You: Tell me more about her.
Searched as: Tell me more about ABC.
The rewritten question is then searched exactly like a first question, with the normal 0.63 threshold. The model still answers your own words; the rewrite is only used for the search.
llama3 isn't reliable enough to do this
unsupervised. An early version sent every question to the
rewriter:
So the rewriter has guard rails:
- Only questions that refer back are sent to it (step 1). "What is the capital of France?" has no referring word, so it's never rewritten.
- Refusals are removed from the conversation it sees. They contain no names to resolve, and they confused it.
- Its output is checked. A rewrite is thrown away if it drops more than 40% of the question's own key words (it swapped in a different question), or if it's much longer than the question (it answered instead of rewriting). Step 3 is used instead.
Step 3: when there's nothing to rewrite
If a follow-up has no referring word, or the rewrite failed or was rejected, LocalCortex searches with the previous question and the new one together. "How many vacation days do I get?" followed by "Can I carry over what I don't use?" is searched as both sentences, so the search knows it's about vacation.
This path has two checks, not one:
- The combined question must reach the normal threshold, 0.63.
- The new question on its own must reach 0.57, just above the highest score any general-knowledge question got during calibration.
Without the second check, an off-topic follow-up borrows relevance from the question before it:
The two follow-ups the default misses are very vague ("Can I carry over what I don't use?"). On their own they score lower than some off-topic questions. On the larger 4-document test set, the default gets 12 of 13 with no off-topic leaks.