AI engineering · 09 of 42

Query Rewriting

Turn conversation into a search query

Scroll

Turn conversation into a search query

People do not talk in search queries. They say “why did it suddenly get so expensive?”, and every word a retriever could use is either a pronoun or a vague adjective.

Query rewriting turns that into an explicit request, pulling in the subject from earlier in the conversation and adding the nouns the corpus is actually indexed on, while keeping what the person meant.

It fixes the commonest failure in conversational retrieval: searching for “it”. The risk runs the other way — a rewrite that drifts answers a question nobody asked, confidently and with citations, so it is worth logging the rewritten query alongside the original.

Retrieval
A CHAT TURN IS NOT A SEARCH QUERY why did it suddenly get so expensive? what a person types a retriever sees "it", "suddenly" and "expensive" and has nothing to match on + context causes of increased LLM token usage and cost the same intent, said in the words the corpus actually uses token dashboard pricing guide incident notes The rewrite resolves the pronoun and adds the nouns the index is built on, while keeping what the person actually asked. Get this wrong in the other direction and you answer a question nobody asked, confidently and with citations.
A conversational question with a pronoun in it, rewritten into a standalone query the index can match.