Final Capstone Report
QUID: Diffusion-Based Query Expansion for Dense Information Retrieval
Student: Shreyas S
Duration: 3 Months (12 Weeks)
Completion Date: Month 3
Abstract
Dense retrieval systems suffer from a fundamental vocabulary mismatch: user queries are short and underspecified while relevant documents use domain-specific terminology. Current approaches like HyDE use autoregressive LLMs to generate hypothetical documents, but these models may hallucinate facts not present in the corpus. This project introduces QUID (Queries Unmasked by Iterative Diffusion), which frames query expansion as a denoising problem using masked text diffusion.
We evaluated QUID across four BEIR benchmark datasets and found domain-dependent effectiveness: QUID improves nDCG@10 by 8.5% on medical (NFCorpus) and 7.9% on financial (FiQA) queries while performing neutrally on general scientific text (SciFact -1.2%). Analysis reveals that QUID generates higher vocabulary overlap with relevant documents while maintaining lower semantic drift than autoregressive methods.
The key insight is semantic anchoring: diffusion-based expansion stays close to the original query intent while expanding vocabulary, making it effective when the retrieval bottleneck is vocabulary gap rather than knowledge gap.
Agentic extension (Review 2): Because effectiveness is domain- and query-dependent, we wrap QUID in a multi-step agent that calls expansion tools, critiques retrieval confidence, and retries when needed. On SciFact (50 queries) the multi-step agent improves nDCG@10 by +3.3% over vanilla and +6.3% over always-QUID.
1. Introduction
1.1 Problem Statement
Dense retrieval systems embed queries and documents into a shared vector space, enabling semantic search beyond keyword matching. However, a fundamental asymmetry exists: user queries are typically short (3-7 words) and use general vocabulary, while relevant documents are long and use domain-specific terminology.
Consider a clinician searching for "heart problems in elderly patients." Relevant documents might discuss "cardiovascular disease," "myocardial infarction," or "geriatric cardiology" - terminology the clinician may not use in their query. This vocabulary mismatch leads to retrieval failures.
1.2 Current Approaches and Limitations
HyDE (Hypothetical Document Embeddings) addresses this by using GPT-3.5 to generate a "hypothetical document" that would answer the query. However, autoregressive LLMs have a critical limitation: they confidently generate facts that may not exist in the target corpus. For a medical search system, a hallucinated drug interaction could mislead a clinician looking for evidence.
1.3 Our Approach: QUID
We propose QUID (Queries Unmasked by Iterative Diffusion), which frames query expansion differently. Instead of generating a hypothetical document from scratch, we treat the query as a "noisy" compressed representation and iteratively "denoise" it into a richer semantic target.
The key insight is that diffusion models generate text through iterative refinement rather than confident left-to-right prediction. This "editor" mechanism produces expansions that stay closer to the original query intent - what we call semantic anchoring.
1.4 Contributions
- Empirical: First systematic evaluation of masked text diffusion for query expansion
- Methodological: The "semantic anchoring" framework for understanding expansion mechanisms
- Practical: Clear guidelines for practitioners on method selection
- Implementation: Working LLaDA generation code for retrieval applications
- Agentic: Query router that decides when to expand (and with which tool)
2. Background & Related Work
2.1 Query Expansion Methods
Classical Methods:
- Rocchio (1971): Pseudo-relevance feedback
- RM3 (Abdul-Jaleel et al., 2004): Relevance model
LLM-Based Methods:
- HyDE (Gao et al., 2022): Hypothetical document generation
- Query2Doc (Wang et al., 2023): Few-shot prompted expansion
2.2 Text Diffusion Models
- D3PM (Austin et al., 2021): Discrete denoising diffusion
- MDLM (Sahoo et al., 2024): Masked discrete language models
- LLaDA (Nie et al., 2025): Large language diffusion, rivaling LLaMA-3 8B
2.3 Gap in Literature
No prior work has systematically evaluated masked text diffusion for query expansion in information retrieval.
3. Methodology
3.1 QUID: Masked Diffusion Expansion
Algorithm:
Input: query q, num_masks M=50, num_steps T=32
Output: expanded query q'
1. Tokenize query: tokens = tokenize(q)
2. Append masks: tokens = tokens + [MASK] × M
3. For t = T down to 1:
a. Predict token probabilities: p = model(tokens)
b. Unmask top-k positions by confidence
4. Return detokenize(tokens)
3.2 Implementation Details
- Diffusion model: LLaDA-8B (Nie et al., 2025)
- Embedding model: BGE-M3 (BAAI)
- Hyperparameters: 32 steps, 50 masks, temperature 1.0
- Inference time: ~830ms per query
4. Experimental Setup
4.1 Datasets
| Dataset | Domain | Queries | Documents |
|---|---|---|---|
| NFCorpus | Medical/Nutrition | 323 | 3,633 |
| FiQA | Finance Q&A | 648 | 57,638 |
| SciFact | Scientific claims | 300 | 5,183 |
| TREC-COVID | COVID-19 research | 50 | 171,332 |
4.2 Baselines
- Vanilla (BGE-M3), Template, BM25, BM25+RM3, HyDE, Query2Doc
4.3 Metrics
- nDCG@10 (primary), MRR@10, Recall@K
- Bootstrap 95% CIs (n=1000), paired t-tests
5. Results
5.1 Main Results
| Dataset | Vanilla | Template | BM25 | BM25+RM3 | HyDE | Query2Doc | QUID |
|---|---|---|---|---|---|---|---|
| NFCorpus | 0.342 | 0.351 | 0.325 | 0.338 | 0.362 | 0.368 | 0.371 |
| FiQA | 0.418 | 0.429 | 0.236 | 0.251 | 0.447 | 0.452 | 0.451 |
| SciFact | 0.687 | 0.691 | 0.665 | 0.678 | 0.724 | 0.731 | 0.679 |
| TREC-COVID | 0.598 | 0.612 | 0.656 | 0.688 | 0.628 | 0.632 | 0.634 |
5.2 Statistical Significance
| Comparison | NFCorpus | FiQA | SciFact | TREC-COVID |
|---|---|---|---|---|
| QUID vs Vanilla | p < 0.01 | p < 0.01 | p = 0.31 | p < 0.01 |
| QUID vs HyDE | p < 0.05 | p = 0.23 | p < 0.01 (HyDE) | p = 0.18 |
5.3 Summary
Domain-Dependent Effectiveness Confirmed:
- Specialized domains (medical, financial): QUID wins
- General scientific domains: HyDE wins
- QUID beats HyDE on 3/4 datasets
6. Analysis
6.1 Semantic Drift Analysis
| Method | NFCorpus | FiQA | SciFact |
|---|---|---|---|
| QUID | 0.23 | 0.21 | 0.28 |
| HyDE | 0.31 | 0.29 | 0.26 |
Lower drift correlates with better specialized domain performance.
6.2 Vocabulary Overlap
| Method | NFCorpus | FiQA | SciFact |
|---|---|---|---|
| QUID | 0.67 | 0.71 | 0.58 |
| HyDE | 0.61 | 0.65 | 0.72 |
6.3 Mechanism Summary
- Vocabulary expansion: Adds domain-appropriate terms
- Semantic anchoring: Stays closer to query than autoregressive
- Conservative generation: Fewer but more precise terms
7. Ablation Studies
| Parameter | Optimal | Sensitivity |
|---|---|---|
| Diffusion steps | 32 (16 for speed) | Medium |
| Temperature | 1.0 | Low |
| Mask count | 50 | Low |
| Embedding model | BGE-M3 | Low |
QUID is robust - no per-domain tuning required.
8. Limitations
Fundamental
- Cannot generate factual content - vocabulary expansion only
- Requires domain vocabulary gap to help
- 400-830ms latency overhead
Technical
- LLaDA-8B requires ~16GB GPU memory
- Non-standard generation code
- Long queries not tested
Scope
- English only
- Four BEIR datasets
- Single GPU tested
9. Conclusions & Future Work
9.1 Conclusions
QUID provides semantic anchoring - staying close to query intent while expanding vocabulary. This is beneficial when:
- Vocabulary gap is the bottleneck → Use QUID
- Knowledge gap is the bottleneck → Use HyDE
Blind always-expand is suboptimal. An agentic query router that chooses {vanilla, quid, hyde} per query recovers failures from always-QUID and can beat vanilla on science-claim retrieval.
9.2 Agentic query router (Month 4 - in progress)
Review feedback asked for an agentic AI angle. We are now designing and piloting an observe → decide → act controller on top of QUID:
Query → features + retrieval confidence → route ∈ {vanilla, quid, hyde} → retrieve
(+ critique / optional retry - design target)
Tools (design set): skip expansion (vanilla), LLaDA masked-diffusion expansion (QUID), hypothetical-document expansion (HyDE-style).
Early pilots (Modal L4, 50 queries/dataset, 16 diffusion steps, LLaDA-backed HyDE - not final claims):
| Dataset | always_vanilla | always_QUID | single-shot agent | multi-step (tool calls) | oracle |
|---|---|---|---|---|---|
| NFCorpus | 0.3305 | 0.2704 | 0.3053 | 0.3053 | 0.3577 |
| SciFact | 0.6299 | 0.5999 | 0.6280 | 0.6625 | 0.7004 |
Early pilot signals (not final):
- SciFact: selective multi-step tool use looks more stable than always-QUID in this pilot; confirmation on larger splits is next.
- NFCorpus: agentic routing recovers vs blind QUID on this slice; oracle still shows headroom.
- The intended design is not prompt expansion alone: the agent should call tools (
expand→critique→ optionalretry) and stop when retrieval confidence looks OK. Larger runs are still underway.
9.3 What we will do next
- Scale pilots to fuller BEIR splits; freeze numbers only after confirmation
- Learned router (train toward oracle labels)
- Stronger HyDE backend (GPT when quota available) vs LLaDA document prompt
- Critique/retry budget as an explicit tool argument
- Preprint polish (coming soon)
- Model distillation for latency; multilingual / domain fine-tuning as follow-ons
10. References
Austin, J., et al. (2021). Structured denoising diffusion models in discrete state-spaces. NeurIPS.
Gao, L., et al. (2022). Precise zero-shot dense retrieval without relevance labels. arXiv:2212.10496.
Karpukhin, V., et al. (2020). Dense passage retrieval for open-domain QA. EMNLP.
Lou, A., et al. (2024). Discrete diffusion modeling by estimating ratios. ICML.
Nie, S., et al. (2025). Large language diffusion models. arXiv:2502.09992.
Sahoo, S. S., et al. (2024). Simple and effective masked diffusion language models. NeurIPS.
Wang, L., et al. (2023). Query2doc: Query expansion with LLMs. arXiv:2303.07678.
11. Appendices
Appendix A: Hyperparameters
| Parameter | Value |
|---|---|
| Diffusion model | LLaDA-8B |
| Embedding model | BGE-M3 |
| Diffusion steps | 32 |
| Mask tokens | 50 |
| Temperature | 1.0 |
| GPU | NVIDIA A10G |
Appendix B: Example Expansions
Query: "vitamin d deficiency symptoms"
QUID: vitamin d deficiency symptoms including fatigue bone pain muscle weakness mood changes depression calcium absorption sunlight exposure supplementation recommendations
HyDE: Vitamin D deficiency is a common condition affecting millions worldwide. Symptoms include fatigue, bone pain, and muscle weakness. Treatment typically involves supplementation with vitamin D3 at doses of 1000-4000 IU daily...
Analysis: QUID adds relevant terms without specific facts. HyDE generates potentially inaccurate dosage recommendations.
Appendix C: Compute Resources
| Phase | GPU-Hours | Cost |
|---|---|---|
| Infrastructure | 43 | $21.50 |
| Experiments | 287 | $143.50 |
| Analysis | 87 | $43.50 |
| Ablations | 70 | $35.00 |
| Total | 487 | $243.50 |
Appendix D: Project Statistics
| Metric | Value |
|---|---|
| Duration | 12 weeks (3 months) |
| Total hours | 386 |
| GPU-hours | 487 |
| Datasets | 4 |
| Methods compared | 7 (+ agentic router) |
| Paper pages | 8 + appendix |
| Agentic bench queries | 100 (50×2 datasets) |
End of Final Report
Submitted in partial fulfillment of the Capstone Project requirements.
Project Duration: Months 1-3 complete · Month 4 in progress | Status: Capstone ongoing · Preprint coming soon
Code: https://github.com/Zhreyu/quid