M7-022M7: Retrieval, Ranking & RecSysHybrid Retrieval & RRF FusionHard
⚡Flashcard Drill➔Mastery:

Explain Query Rewriting and Expansion Techniques in Modern Information Retrieval

🎯 Active Recall Self-Check (Draft First, Verify After)
Login-free practice tracker: recall core answer, audit pitfalls, and log review status.
Step 1 · Draft your concise answer & assumptions
Step 2 · Check Pitfalls & Follow-up Inquiries
Next: M7-023 →
📐 Mathematical Definition
rewrite: q→q′;expand: q→q+Δ;risk: query drift\text{rewrite}:\ q\to q';\qquad \text{expand}:\ q\to q+\Delta;\qquad \text{risk}:\ \text{query drift}
⚡ One-Sentence Core Answer
Query rewriting refines, disambiguates, and decomposes user queries, while query expansion appends synonyms and related terms; techniques range from classical pseudo-relevance feedback (PRF) to LLM-generated hypothetical documents (HyDE).

📌 Key Takeaways

  • •
    Rewriting vs. expansion: Rewriting transforms flawed queries (spelling correction, coreference resolution, multi-hop decomposition); expansion adds relevant vocabulary.
  • •
    Query drift hazard: Over-aggressive expansion introduces irrelevant topical associations, degrading precision.
  • •
    Generative methods (HyDE): LLMs generate hypothetical answer passages that dense retrievers use as rich semantic search vectors.

📐 Mathematical Derivations

Systematic & Methodological Formulation: Query Transformation Strategies.

(1) Classical Pseudo-Relevance Feedback (PRF / RM3):
Assumes top-kk retrieved documents Dk={d1,…,dk}D_k = \{d_1, \dots, d_k\} from an initial BM25 search are pseudo-relevant. It estimates a feedback language model P(w∣θF)P(w \mid \theta_F):
P(w∣θF)=∑d∈DkP(w∣d)P(d∣q)P(w \mid \theta_F) = \sum_{d \in D_k} P(w \mid d) P(d \mid q)
The expanded query model is a linear interpolation between original query model θQ\theta_Q and feedback model θF\theta_F:
P(w∣θ~Q)=(1−α)P(w∣θQ)+αP(w∣θF)P(w \mid \tilde{\theta}_Q) = (1 - \alpha) P(w \mid \theta_Q) + \alpha P(w \mid \theta_F)
Top expanded terms with highest probability are appended to the original query.

(2) Hypothetical Document Embeddings (HyDE, Gao et al., 2022):
For complex queries where direct question-document similarity is weak:
- Step 1: Instruct an LLM to generate a zero-shot hypothetical answer dhypo∼PLLM(d∣q)d_{\text{hypo}} \sim P_{\text{LLM}}(d \mid q). (Even if factually incorrect, its language and topical structure mirror real target documents).
- Step 2: Encode the hypothetical document: vhypo=ED(dhypo)v_{\text{hypo}} = E_D(d_{\text{hypo}}).
- Step 3: Retrieve real documents via vector similarity s(dhypo,dreal)=vhypoTED(dreal)s(d_{\text{hypo}}, d_{\text{real}}) = v_{\text{hypo}}^T E_D(d_{\text{real}}).

(3) Multi-Turn Conversational Coreference & Disambiguation:
In conversational search, user queries contain elliptical references: qt=’how much does it cost?’q_t = \text{'how much does it cost?'}. An LLM rewriter conditions on session history H<tH_{<t}:
qrewritten=LLM(qt,H<t)  ⟹  ’how much does Tesla Model Y cost in 2024?’q_{\text{rewritten}} = \text{LLM}(q_t, H_{<t}) \implies \text{'how much does Tesla Model Y cost in 2024?'}

🏭 Production Trade-offs

In-Depth Analysis & Engineering Trade-offs: ① The query drift risk—if the initial retrieval or LLM hallucination is topically flawed, PRF or HyDE severely magnifies the error, pulling irrelevant documents into the recall set; selective rewriting based on query ambiguity confidence is critical. ② Latency overhead of LLM rewriting—calling a 7B LLM to rewrite or expand queries introduces 100–300ms latency, making it unsuitable for 50ms search SLAs; production search deploys distilled 100M-parameter sequence-to-sequence models or cached rewrite dictionaries for online paths. ③ Exact keyword preservation—rewriting must never alter or drop critical technical tokens (product SKUs, error numbers, exact names); production rewriters lock recognized named entities. ④ Multi-query parallel search—generating 3 diverse query reformulations and executing parallel searches followed by RRF fusion significantly improves recall on ambiguous queries at the cost of 3x search compute. ⑤ HyDE vs. query-to-query dense retrieval—HyDE bridges the asymmetric question-passage gap by converting search into a symmetric document-to-document match, excelling at complex analytical queries. ⑥ Interview takeaway—distinguish query rewriting (spelling, coreference, intent decomposition) from query expansion (synonym injection, PRF, HyDE), explain the query drift failure mode, and discuss latency mitigation strategies.
⚠️ Common Interview Pitfalls
  • ✕
    Applying blind query expansion to specific, long-tail technical queries, introducing semantic drift and degrading precision.
  • ✕
    Deploying heavy generative LLM rewriters directly on synchronous latency-critical search pipelines without aggressive caching or distillation.
  • ✕
    Permitting query rewriting models to alter or discard exact entity identifiers (e.g., error codes, model numbers).
🎯 Interviewer Follow-up Inquiries
  • ?
    Why does HyDE succeed in retrieving relevant documents even when the generated hypothetical passage contains factual hallucinations?
  • ?
    How can a search system detect query ambiguity to decide whether to trigger query expansion dynamically?
  • ?
    What distillation techniques compress 7B LLM conversational query rewriting into a sub-10ms latency budget?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

← PreviousM7-021: Explain Multi-Channel Candidate Generation (Multi-Channel Retrieval) and Quota Allocation Strategies📋 Back to BankNext →M7-023: Explain Training-Serving Consistency and Feature Skew in Search and Retrieval Systems