What query understanding techniques would you apply before retrieval, and when is each worth it?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Raw user queries are hostile to retrieval: vague, multi-intent, phrased as questions while your corpus is statements. The toolbox, roughly in order of adoption:
Query rewriting: an LLM normalizes the query - strips fluff, expands acronyms, fixes typos, and (critically, in chat) resolves references against conversation history: "what about for enterprise?" → "what is the SSO configuration process for enterprise-tier customers?". Non-negotiable for conversational RAG; nearly free with a small fast model.
Full worked answer with diagram
Raw user queries are hostile to retrieval: vague, multi-intent, phrased as questions while your corpus is statements. The toolbox, roughly in order of adoption:
Query rewriting: an LLM normalizes the query - strips fluff, expands acronyms, fixes typos, and (critically, in chat) resolves references against conversation history: "what about for enterprise?" → "what is the SSO configuration process for enterprise-tier customers?". Non-negotiable for conversational RAG; nearly free with a small fast model.
Multi-query expansion: generate 3-5 paraphrases/variants, retrieve for each in parallel, fuse with RRF. Insurance against embedding-space luck - different phrasings land in different neighbourhoods. Cheap quality win; costs one small LLM call plus parallel searches.
HyDE (Hypothetical Document Embeddings): have the LLM write a hypothetical answer to the query and embed that instead of (or alongside) the query. Rationale: questions and answers are asymmetric in embedding space - a fabricated answer paragraph looks distributionally like the real document you're hunting. Shines for zero-shot retrieval with no tuned embedder; risks drift when the LLM's guess is wrong-domain, so fuse with the raw-query results rather than replacing them.
Decomposition: split multi-hop questions ("Compare our churn in EMEA vs the industry benchmark") into sub-queries retrieved independently, then synthesise. This is the gateway to agentic RAG - at some complexity you let the model loop rather than pre-planning.
Routing: classify the query to pick the right corpus/index/tool (HR wiki vs codebase vs CRM; or "needs SQL, not vector search"). Usually a cheap classifier or small-LLM call; essential once you have heterogeneous sources.
Cost note: every technique adds an LLM call before retrieval even starts - 100-500ms each. Standard mitigations: use a small fast model for rewriting, run expansions concurrently, and gate sophistication by query difficulty (a router that sends easy queries straight to retrieval).
Worth sketching. It shows these are independently gateable stages rather than one blob of preprocessing, which is where the latency budget is won.
flowchart LR
U["Raw user turn"] --> RW["Rewrite: resolve references,<br/>expand acronyms"]
RW --> RT{"Route: which corpus<br/>or tool?"}
RT -->|"structured data"| SQL["Text-to-SQL path"]
RT -->|"unstructured"| EX["Expand to 3-5 variants,<br/>optionally a HyDE answer"]
EX --> S["Retrieve each<br/>in parallel"]
S --> F["RRF fuse"]
F --> RR["Rerank"]
What a good answer covers
- Raw user queries are hostile to retrieval
- Query rewriting: an LLM normalizes the query - strips fluff, expands acronyms, fixes typos, and…
- Non-negotiable for conversational RAG; nearly free with a small fast model
- Multi-query expansion: generate 3-5 paraphrases/variants, retrieve for each in parallel, fuse with RRF
- Insurance against embedding-space luck - different phrasings land in different neighbourhoods
Key terms: Query rewriting · Multi-query expansion · HyDE · Decomposition · Routing
In the glossary: Query rewriting · RRF · HyDE · Zero-shot · Agentic RAG · Router
Interviewer follow-ups to expect
How do you measure whether query rewriting is actually helping?
Query rewriting: an LLM normalizes the query - strips fluff, expands acronyms, fixes typos, and (critically, in chat) resolves references against conversation history: "what about for enterprise?" → "what is the SSO configuration process for enterprise-tier customers?". Non-negotiable for conversational RAG; nearly free with a small fast model.
When does HyDE hurt?
HyDE (Hypothetical Document Embeddings): have the LLM write a hypothetical answer to the query and embed that instead of (or alongside) the query. Rationale: questions and answers are asymmetric in embedding space - a fabricated answer paragraph looks distributionally like the real document you're hunting. Shines for zero-shot retrieval with no tuned embedder; risks drift when the LLM's guess is wrong-domain, so fuse with the raw-query results rather than replacing them.
How would you keep total pre-retrieval latency under 300ms while using these?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep