Course contentsShow
← Machine Learning and Deep Learning
Lesson 2016 of 3,53843. Retrieval-Augmented Generation: Advanced TechniquesFree lesson

LLM-Based Query Reformulation

Using language models to rephrase user queries into forms more likely to match document vocabulary and structure.

LLM-Based Query Reformulation

What you'll learn: How to use language models to automatically transform user queries into more retrieval-friendly versions that better match your document collection.

The Core Problem

Users often phrase questions in ways that don't align with how documents are written. Someone might ask "How do I fix my broken AC?" when documents use formal language like "troubleshooting air conditioning malfunctions." This vocabulary mismatch causes relevant documents to be missed during retrieval.

How LLM-Based Reformulation Works

Instead of searching with the user's original question, you first pass it through an LLM with instructions to rephrase it in a way that's more likely to match your document style. The LLM understands both casual and formal language, making it perfect for this translation task.

The pattern:

  1. User asks a question in their natural style
  2. LLM rewrites it to match document vocabulary and structure
  3. Reformulated query is used for retrieval
  4. Better matches are found

Why This Works Better Than Query Expansion

Unlike query expansion (which adds synonyms), LLM reformulation can completely restructure the question, change writing style, add domain terminology, and even convert implicit questions into explicit ones. It's like having a librarian who knows both how patrons speak and how your books are catalogued.

You might combine this with other techniques like HyDE (which generates hypothetical answers) by having the LLM reformulate the query toward the expected format of your documents rather than generating full answers.

Key Takeaway: LLM-based query reformulation bridges the gap between how users naturally ask questions and how information is formally documented, significantly improving retrieval accuracy by leveraging the language model's understanding of context, style, and domain vocabulary.