If you work on conversational RAG, sooner or later you will encounter query rewriting. I am really struggling with it. To explain the problem here is an example conversation and what I do to resolve pronouns and query history context:
The conversation is about hedgehogs (what else).
User: Tell me about hedgehogs
Assistant: Provides information about hedgehogs.
User: What do they eat?
Assistant: Earthworms, beetles, slugs, caterpillars, millipedes, earwigs, and spiders. Snails if nothing else is available.
What does query rewriting do?
The query first enters salient referent resolution. At the moment of writing, I use heuristic scoring of recent topic mentions, grammatical role, singular/plural, main noun and mention frequency.
If a candidate passes the confidence threshold they is replaced with hedgehogs:
Retrieval query: What do hedgehogs eat?
If the reference remains missing or ambiguous, the query is marked underspecified. In this case a LLM attempts a rewrite using only the newest assistant answer. The LLM answer must pass validation.
If the validation fails or no answer exists the user gets an explanation of the failure and is asked to clarify her query.
Why is it difficult?
User: Are they mammals?
Or: Is it a mammal?
The user knows they mean hedgehogs. Conversional RAG must establish that connection from the available conversation and grammatical signals. Multiple candidate subjects, singular/plural differences, and ambiguous wording make this difficult.
Query splitting
User: What do hedgehogs eat? Create a table.
Retrieval question: What do hedgehogs eat?
Answer operation: Create a table.
After reference resolution succeeded, the splitter separates the query content from the answer instructions. "Create a table" is an irrelevant search term for the indexed queries. This is done through a LLM call. A decomposition that invents entities or drops unresolved references is once retried with additional instructions to preserve references and avoid invented entities. A simple standalone question can be retained instead of a rejected split. Other failures produce a clarification request to the user.
Translation
Each accepted retrieval question is normalized according to the selected retrieval-language mode. English-oriented flows translate when required; native multilingual flows retain the query language. Indexed retrieval can translate the retrieval query into the configured target languages before searching. (Document load created language specific indexes).
Retrieval gates block still queries marked underspecified. Therefore changing the language will not resolve uncertainty about what they or diese means.
Conclusion
Modern chat LLMs handle query rewrite remarkably well. Users might forget what is required to connect "they, it" to earlier turns.
Building a conversational RAG system makes the problem visible. The retrieval layer requires an explicit standalone query. So the conversational RAG must provide it, without inventing never mentioned entities.
Because modern chat LLMs handle this so reliably, there must be techniques beyond the simple heuristics I use currently.
How do you solve this problem?
- Classical coreference resolution?
- LLM-based rewriting?
- Embedding similarity against conversation history?
- Conversation memory structures?
- Something else?
Thank you for your ideas!