---
id: TECH-RAG-001
title: "Retrieval-Augmented Generation"
alternative_names:
  - "RAG"
  - "Retrieval-Augmented Language Models"
  - "Grounded Generation"
category: "Technical → Language Models"
volume: III
chapter: 19
entry_type: "Technical Article"
level: 3
status: "Draft"
last_reviewed: 2026-10-15
version: "0.1.0"
prerequisites:
  - "TECH-LLM-001"
  - "TECH-TOK-001"
related_entries:
  - "TECH-ARCH-001"
  - "TECH-AGENT-001"
  - "CAP-LIMITS-001"
  - "SAFE-SEC-001"
  - "TECH-DATA-001"
---

# Retrieval-Augmented Generation

## 1. Concise Definition
**Retrieval-Augmented Generation (RAG)** is a technique in which a language model's output is conditioned on documents retrieved from an external collection at inference time, so that the model draws on explicit, updatable non-parametric memory in addition to the knowledge stored in its weights (its parametric memory). The term was introduced by Lewis et al. (2020) for models combining a pre-trained sequence-to-sequence generator with a dense retrieval index, and is now used more broadly for any pipeline that retrieves text and places it in a model's context.

## 2. Overview & Significance
A trained language model holds a fixed snapshot of its training data, cannot cite where a statement came from, and has no access to private documents. Lewis et al. (2020) identify these as open problems: precisely accessing and manipulating knowledge, providing provenance for decisions, and updating world knowledge. Retrieval addresses them by separating knowledge storage from the generator: the collection can be changed without retraining, and the passages used can be shown to the user.

RAG is a mitigation, not a guarantee. Retrieval can return irrelevant or conflicting passages, and a model can ignore or misuse correct ones (Section 7). It is also not the only means of giving a model fresh information: long-context prompting, tool use by agents (see [TECH-AGENT-001]), and fine-tuning are alternatives or complements, and a production system often combines several.

## 3. Historical Development
Sparse retrieval, in which documents are scored by weighted term overlap (TF-IDF and the BM25 family; Robertson & Zaragoza, 2009), predates neural methods and remains a strong baseline. The BEIR benchmark (Thakur et al., 2021) evaluated 10 retrieval systems on 18 datasets and found BM25 a robust zero-shot baseline, with re-ranking and late-interaction models achieving the best average zero-shot results at high computational cost.

Neural retrieval-augmented language modelling developed in several strands. REALM (Guu et al., 2020) pre-trained a latent knowledge retriever with a masked-language-modelling signal, back-propagating through retrieval over millions of documents, and reported 4–16% absolute accuracy gains over prior methods on three open-domain QA benchmarks. Dense Passage Retrieval (Karpukhin et al., 2020) used a dual-encoder trained on a small number of question-passage pairs and reported 9–19% absolute gains in top-20 passage accuracy over a Lucene-BM25 system. Fusion-in-Decoder (Izacard & Grave, 2021) showed that a generative reader improves as the number of retrieved passages increases. RAG (Lewis et al., 2020) combined a dense Wikipedia index with a pre-trained seq2seq generator and compared two formulations. RETRO (Borgeaud et al., 2022) conditioned an autoregressive model on chunks retrieved from a 2-trillion-token database through chunked cross-attention and reported performance comparable to GPT-3 and Jurassic-1 on the Pile with 25 times fewer parameters. Atlas (Izacard et al., 2023) studied few-shot learning with retrieval-augmented models and reported over 42% accuracy on Natural Questions with 64 examples, outperforming a 540B-parameter model by 3% with 50 times fewer parameters.

From 2022, as instruction-tuned models became widely available, a simpler pattern predominated: retrieve text with an off-the-shelf retriever and prepend it to the prompt of a frozen model. REPLUG (Shi et al., 2024) formalised this black-box setting and showed that the language model can supervise the retriever. The pattern now commonly called "naive RAG" and its refinements are surveyed by Gao et al. (2023).

## 4. Technical / Conceptual Explanation

### 4.1 The basic pipeline
1. **Indexing.** Documents are split into chunks, each chunk is mapped to a vector by an embedding model (see [TECH-TOK-001]) and stored with its text in a vector index; a sparse (BM25) index may be built in parallel.
2. **Retrieval.** The query is embedded and the $k$ nearest chunks are retrieved by similarity, commonly cosine similarity $\mathrm{sim}(q, d) = \dfrac{\mathbf{q}\cdot\mathbf{d}}{\lVert\mathbf{q}\rVert\,\lVert\mathbf{d}\rVert}$, using approximate nearest-neighbour search for large collections.
3. **(Optional) Re-ranking.** A more expensive model rescoring the top candidates. ColBERT (Khattab & Zaharia, 2020) is a late-interaction design that encodes query and document independently and models their fine-grained similarity after, so document representations can be pre-computed offline.
4. **Augmented generation.** The retrieved text is concatenated with the question in the prompt, and the model generates an answer, optionally with citations.

### 4.2 Probabilistic formulation
In the original RAG model (Lewis et al., 2020) a retriever $p_\eta(z \mid x)$ gives a distribution over passages $z$ for input $x$, and a generator $p_\theta(y \mid x, z)$ produces the output. The passages are treated as a latent variable and marginalised over the top $k$ retrieved. The "sequence" formulation conditions on the same passage across the whole output:
$$ p(y \mid x) \approx \sum_{z \in \text{top-}k\,p_\eta(\cdot\mid x)} p_\eta(z \mid x)\, \prod_{i} p_\theta(y_i \mid x, z, y_{<i}), $$
while the "token" formulation marginalises per token and so can use different passages at different positions:
$$ p(y \mid x) \approx \prod_{i} \sum_{z \in \text{top-}k} p_\eta(z \mid x)\, p_\theta(y_i \mid x, z, y_{<i}). $$
In contemporary prompt-based pipelines there is no explicit marginalisation; the retrieved text simply forms part of the context, $p_\theta(y \mid x, d_1,\dots,d_k)$.

### 4.3 Training and integration choices
- **Frozen versus trained components.** Retriever and generator can be trained jointly (REALM, RAG, Atlas), the retriever can be trained from generator feedback (REPLUG), or both can be used off the shelf.
- **Where retrieved text enters.** In the prompt (REPLUG, most deployed systems), via cross-attention to retrieved chunks (RETRO), or by encoding each passage separately and fusing in the decoder (Fusion-in-Decoder).
- **Adaptive retrieval.** Self-RAG (Asai et al., 2024) trains a single model to decide when to retrieve and to critique retrieved passages and its own generations with special reflection tokens; the authors report that 7B and 13B versions outperform ChatGPT and a retrieval-augmented Llama 2-chat on open-domain QA, reasoning and fact verification, and improve factuality and citation accuracy for long-form generation relative to the models they compared.
- **Structured and graph indexes.** GraphRAG (Edge et al., 2024) uses an LLM to derive an entity knowledge graph and pre-generate community summaries so that "global" questions about a whole corpus, which conventional RAG handles poorly, can be answered; the authors report improved comprehensiveness and diversity of answers on datasets in the 1-million-token range.

## 5. Types, Components & Classifications

| Variant | Retriever | How the generator uses text | Examples |
| :--- | :--- | :--- | :--- |
| Sparse-retrieval RAG | BM25 / TF-IDF | Prompt | Common baselines (Robertson & Zaragoza, 2009) |
| Dense RAG | Dual-encoder embeddings | Prompt or latent-variable marginalisation | Karpukhin et al. (2020); Lewis et al. (2020) |
| Late-interaction retrieval | Token-level embeddings | Prompt | Khattab & Zaharia (2020) |
| Retrieval pre-trained into the LM | Jointly trained | Cross-attention or fusion | REALM; RETRO; Atlas |
| Black-box RAG | Tunable external | Prepended to frozen model | REPLUG |
| Self-reflective / adaptive RAG | On-demand | Critique tokens decide retrieval | Self-RAG |
| Graph / hierarchical RAG | Graph index plus summaries | Partial answers combined | GraphRAG |

The survey by Gao et al. (2023) organises the field into Naive RAG, Advanced RAG (pre- and post-retrieval refinements such as query rewriting and re-ranking) and Modular RAG, and examines retrieval, generation and augmentation techniques separately.

## 6. Applications & Concrete Examples
- **Open-domain question answering**, the setting of REALM, DPR, Fusion-in-Decoder, RAG and Atlas.
- **Enterprise and private-document assistants**, where the collection is non-public and changes frequently. Public descriptions of commercial products usually do not specify retrieval architecture; specifics for closed products are **undisclosed** unless the vendor documents them.
- **Search-augmented assistants**, in which a web-search tool supplies the documents; this is a deployed pattern, but ranking, filtering and citation-selection details are not generally disclosed.
- **Query-focused summarisation of large corpora** (GraphRAG), reported as research results by Edge et al. (2024) rather than as an independently benchmarked product.

## 7. Advantages, Limitations & Unresolved Questions

### Advantages
Updatable knowledge without retraining; provenance through citation of retrieved text; ability to work over private collections; and in several studies, similar or better accuracy than much larger models on knowledge-intensive tasks (Borgeaud et al., 2022; Izacard et al., 2023).

### Limitations
- **Using context imperfectly.** Liu et al. (2024) find that performance on multi-document QA and key-value retrieval can degrade significantly when relevant information is in the middle of a long input context, even for explicitly long-context models; accuracy is often highest at the beginning or end.
- **Retrieval quality is not monotone in "relevance".** Cuconasu et al. (2024) report that high-scoring retrieved documents that do not contain the answer negatively affect the LLM, and, as a counter-intuitive finding, that adding random documents to the prompt improved accuracy by up to 35% in their setup. The result shows that the interaction between retrieved context and the model is not well characterised; it is not a recommendation to add random text.
- **Evaluation is multi-dimensional.** Ragas (Es et al., 2024) proposes reference-free metrics separating retrieval relevance, faithful use of the context and generation quality, because a correct final answer can hide a retrieval failure and vice versa. Automated metrics of this kind depend on an LLM judge and are themselves approximations.
- **Global questions.** Standard RAG is an explicit retrieval method and fails on questions about a whole corpus (Edge et al., 2024).
- **Security and integrity.** Retrieved text is untrusted input that is placed in the model's context; instructions embedded in documents can influence the model, and the index can be poisoned (see [SAFE-SEC-001]).
- **Hallucination persists.** Grounding reduces but does not eliminate unsupported statements (see [CAP-LIMITS-001]).

### Unresolved questions
1. How best to combine retrieval with very long context windows, and when retrieval remains necessary.
2. Principled criteria for the number, ordering and filtering of retrieved passages, given the position and noise effects above.
3. Reliable, low-cost evaluation of faithfulness to retrieved sources.

## 8. Current State of Knowledge
As of 2026-10-15, retrieval-augmented pipelines are a standard way to connect language models to external text, with a mature set of components (dense and sparse retrievers, re-ranking, chunking and prompt assembly) documented in the academic literature and surveys. The strongest published evidence consists of benchmark comparisons on knowledge-intensive tasks, mostly with models and collections specific to each paper. Claims about the effect of RAG on real-world factual accuracy in a given product depend on the retrieval corpus and are not general. Specific architectures of closed commercial retrieval features are **undisclosed**. Model and system details are tracked in `MODEL-001`.

## 9. Future Trajectory & Strategic Outlook
Observed directions: adaptive retrieval decided by the model (Self-RAG), graph and hierarchical indexes (GraphRAG), reference-free evaluation (Ragas), and integration with tool-using agents (see [TECH-AGENT-001]). The extent to which longer context windows or in-weights memory will replace retrieval is an open question; no forecast record is registered in this article.

## 10. Related Entries & Knowledge Graph
- **Foundational Concepts**:
  - [[TECH-LLM-001] Large Language Models](./TECH-LLM-001_large_language_models.md): The generators used in RAG.
  - [[TECH-TOK-001] Tokenization and Embeddings](./TECH-TOK-001_tokenization_and_embeddings.md): Embedding models and chunk sizes in tokens.
- **Related Methods & Technologies**:
  - [[TECH-ARCH-001] The Transformer Architecture](./TECH-ARCH-001_transformer_architecture.md): Cross-attention and context windows.
  - [[TECH-AGENT-001] Autonomous Agents](./TECH-AGENT-001_autonomous_agents.md): Retrieval as one tool among many.
  - [[TECH-DATA-001] Training Data, Contamination and Provenance](./TECH-DATA-001_training_data_contamination_and_provenance.md): Provenance of indexed material.
- **Advanced Implications & Future Trajectories**:
  - [[CAP-LIMITS-001] Hallucination, Reliability and Calibration](../vol04_capabilities/CAP-LIMITS-001_hallucination_reliability_and_calibration.md): What retrieval does and does not fix.
  - [[SAFE-SEC-001] AI Security: Prompt Injection, Poisoning, Extraction](../vol08_safety_governance/SAFE-SEC-001_ai_security_prompt_injection_poisoning_extraction.md): Untrusted retrieved content.

## 11. References & Foundational Literature
1. Robertson, S., & Zaragoza, H. (2009). *The Probabilistic Relevance Framework: BM25 and Beyond*. Foundations and Trends in Information Retrieval, 4(1–2), 1–174. https://doi.org/10.1561/1500000019. [BM25 and the probabilistic relevance framework underlying sparse retrieval].
2. Guu, K., Lee, K., Tung, Z., Pasupat, P., & Chang, M.-W. (2020). *REALM: Retrieval-Augmented Language Model Pre-Training*. ICML 2020. arXiv:2002.08909. [Unsupervised pre-training of a latent retriever; 4–16% absolute gains on three Open-QA benchmarks].
3. Karpukhin, V., Oğuz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., & Yih, W. (2020). *Dense Passage Retrieval for Open-Domain Question Answering*. Proceedings of EMNLP 2020. arXiv:2004.04906. [Dual-encoder dense retrieval; 9–19% absolute top-20 gains over BM25].
4. Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W., Rocktäschel, T., Riedel, S., & Kiela, D. (2020). *Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks*. NeurIPS 2020. arXiv:2005.11401. [Introduces RAG with parametric and non-parametric memory and two formulations].
5. Izacard, G., & Grave, E. (2021). *Leveraging Passage Retrieval with Generative Models for Open Domain Question Answering*. Proceedings of EACL 2021. arXiv:2007.01282. [Fusion-in-Decoder; accuracy improves with more retrieved passages].
6. Khattab, O., & Zaharia, M. (2020). *ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT*. SIGIR 2020. arXiv:2004.12832. [Late-interaction ranking with pre-computable document representations].
7. Borgeaud, S., Mensch, A., Hoffmann, J., et al. (2022). *Improving language models by retrieving from trillions of tokens*. ICML 2022. arXiv:2112.04426. [RETRO with a 2-trillion-token database and 25x fewer parameters than GPT-3-class baselines on the Pile].
8. Izacard, G., Lewis, P., Lomeli, M., Hosseini, L., Petroni, F., Schick, T., Dwivedi-Yu, J., Joulin, A., Riedel, S., & Grave, E. (2023). *Atlas: Few-shot Learning with Retrieval Augmented Language Models*. arXiv preprint arXiv:2208.03299. [Few-shot retrieval-augmented model; 64-example Natural Questions result].
9. Shi, W., Min, S., Yasunaga, M., Seo, M., James, R., Lewis, M., Zettlemoyer, L., & Yih, W. (2024). *REPLUG: Retrieval-Augmented Black-Box Language Models*. Proceedings of NAACL 2024. arXiv:2301.12652. [Frozen black-box LM with a tunable retriever supervised by the LM].
10. Thakur, N., Reimers, N., Rücklé, A., Srivastava, A., & Gurevych, I. (2021). *BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models*. NeurIPS 2021 Datasets and Benchmarks. arXiv:2104.08663. [Zero-shot retrieval benchmark over 18 datasets; BM25 as a robust baseline].
11. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2024). *Lost in the Middle: How Language Models Use Long Contexts*. Transactions of the ACL, 12. arXiv:2307.03172. [Position effect in use of long input contexts].
12. Asai, A., Wu, Z., Wang, Y., Sil, A., & Hajishirzi, H. (2024). *Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection*. ICLR 2024. arXiv:2310.11511. [Adaptive retrieval and self-critique with reflection tokens].
13. Cuconasu, F., Trappolini, G., Siciliano, F., Filice, S., Campagnano, C., Maarek, Y., Tonellotto, N., & Silvestri, F. (2024). *The Power of Noise: Redefining Retrieval for RAG Systems*. SIGIR 2024. arXiv:2401.14887. [Effect of non-relevant and random documents on RAG accuracy].
14. Edge, D., Trinh, H., Cheng, N., Bradley, J., Chao, A., Mody, A., Truitt, S., Metropolitansky, D., Ness, R. O., & Larson, J. (2024). *From Local to Global: A Graph RAG Approach to Query-Focused Summarization*. arXiv:2404.16130. [GraphRAG for corpus-level questions].
15. Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., Dai, Y., Sun, J., Wang, M., & Wang, H. (2023). *Retrieval-Augmented Generation for Large Language Models: A Survey*. arXiv:2312.10997. [Naive, Advanced and Modular RAG taxonomy].
16. Es, S., James, J., Espinosa-Anke, L., & Schockaert, S. (2024). *Ragas: Automated Evaluation of Retrieval Augmented Generation*. Proceedings of EACL 2024 (System Demonstrations). arXiv:2309.15217. [Reference-free RAG evaluation metrics].

## 12. Evidential Classification Matrix
| Section / Claim | Evidence Category | Supporting Source | Confidence / Status |
| :--- | :--- | :--- | :--- |
| RAG architecture: retrieval plus generation, latent-variable formulation | Established | Lewis et al. (2020) | High |
| Dense retrieval can outperform BM25 on open-domain QA | Well Supported | Karpukhin et al. (2020); but Thakur et al. (2021) find BM25 robust zero-shot | Moderate-High (setting dependent) |
| Retrieval-augmented models can match much larger parametric models on knowledge tasks | Well Supported | Borgeaud et al. (2022); Izacard et al. (2023) | Moderate-High (task and benchmark dependent) |
| Models use middle-of-context information less reliably | Well Supported | Liu et al. (2024) | Moderate-High (tested models) |
| Non-relevant retrieved text can hurt; random text can help | Preliminary | Cuconasu et al. (2024) | Low-Moderate |
| Adaptive retrieval (Self-RAG) outperforms fixed retrieval | Preliminary | Asai et al. (2024) | Moderate |
| GraphRAG improves global-question answers | Preliminary | Edge et al. (2024) | Moderate (authors' evaluation) |
| Architecture of closed commercial retrieval features | Undisclosed | n/a | Not inferred |

## 13. Revision History
- **v0.1.0** (2026-10-15): Initial draft. Citations checked against arXiv/Crossref/publisher pages where marked; not independently fact-checked.
