What is Query Rewriting?
Query rewriting is the technique of transforming user queries into alternative formulations that are more effective for retrieval systems. Rather than searching with the user's exact query, the system analyzes the information need and generates a rewritten query optimized for finding relevant information. This addresses cases where user queries are ambiguous, poorly formed, too broad, too narrow, or simply not aligned with how information is expressed in the knowledge base.
Rewriting can take many forms: clarifying vague queries by adding specificity, decomposing complex questions into simpler sub-queries, converting conversational language to keywords or technical terms, resolving pronouns and references using conversation context, or transforming questions into statement form that better matches document content. Modern systems often use LLMs for query rewriting, leveraging their language understanding to interpret user intent and generate improved query formulations.
Query rewriting is increasingly important in conversational AI and agent systems where users might phrase queries informally, use pronouns that require context resolution, or ask complex multi-part questions. The technique can dramatically improve retrieval quality by bridging the gap between how users naturally express information needs and how retrieval systems process queries. In agentic RAG systems, query rewriting might be applied iteratively, with the agent reformulating queries based on initial retrieval results to progressively refine its information gathering.