Query Rewriting

Category: Generative AI / LLM

A pre-retrieval technique that reformulates the user query to improve retrieval effectiveness, often using a language model to generate optimized search queries.

Full Explanation

Query rewriting transforms user queries into forms that are more effective for retrieval, addressing the common mismatch between how users ask questions and how relevant information is expressed in documents. Techniques include using an LLM to expand the query with related terms, generating hypothetical answer passages (HyDE), decomposing complex queries into simpler sub-queries, and reformulating conversational follow-up questions into standalone queries. Query rewriting is a key pre-retrieval optimization in advanced RAG pipelines. For example, a vague query like "How does it work?" in a conversation about solar panels would be rewritten as "How do solar panels convert sunlight into electricity?" Step-back prompting generates broader queries to capture background knowledge. Query rewriting is one of the highest-impact improvements for RAG systems and can be implemented with minimal infrastructure changes.

Related Terms

More in Generative AI / LLM

Explore More