RETRO, short for Retrieval-Enhanced Transformer, is a language model architecture that conditions text generation on passages retrieved from a very large external database, so that part of its knowledge lives in an index rather than in its weights. Introduced by DeepMind in late 2021, it is a landmark design in the Retrieval & knowledge area of artificial intelligence because it showed that a 7.5-billion-parameter model with retrieval could match the language modeling quality of models roughly 25 times larger on several benchmarks.
Unlike RAG pipelines that paste retrieved text into a prompt, RETRO builds retrieval into the network itself. A dedicated mechanism called chunked cross-attention lets each segment of the input attend to its own retrieved neighbors during both training and inference.
How RETRO retrieves and integrates text
RETRO splits every input sequence into fixed chunks of 64 tokens. For each chunk, it looks up the nearest neighbors in a retrieval database using embeddings from a frozen, pretrained BERT model, averaged over the chunk. Because the embedding model is frozen, the database index can be computed once and never needs to be rebuilt during training.
Each retrieved neighbor consists of the matching database chunk plus its continuation, giving about 128 tokens of context per neighbor. The neighbors pass through a bidirectional transformer encoder that is itself conditioned on the activations of the query chunk. The main decoder then reads these encoded neighbors through chunked cross-attention layers inserted at regular intervals, for example every third layer.
A strict causality constraint shapes the design. Neighbors retrieved for chunk n may influence only the tokens of chunk n and later, never earlier tokens, so the model remains a valid autoregressive language model. In practice, the attention is shifted so the last token of a chunk and the following chunk use that chunk’s neighbors.
The table below lists the main components and the values reported for the original configuration.
| Component | Original setting | Purpose |
|---|---|---|
| Chunk size | 64 tokens | Unit of retrieval and attention |
| Neighbors per chunk | Usually 2 | Supplies supporting text |
| Retriever embeddings | Frozen BERT, averaged | Fixed keys for the index |
| Nearest neighbor search | Approximate, via SCaNN | Sublinear lookup over trillions of tokens |
| Retrieval database | About 2 trillion tokens | External, updatable knowledge store |
| Decoder size | 172M to 7.5B parameters | Model family evaluated |
Chunked cross-attention explained
Chunked cross-attention (CCA) is the operation that makes RETRO efficient. Instead of letting every token attend to every retrieved passage for the whole sequence, each chunk attends only to its own neighbors. The cost therefore grows linearly with the number of retrieved chunks, rather than quadratically as it would if all passages were concatenated into one long context.
This locality also explains a key property: the model can use many more retrieved tokens than its own context window would allow. A 2,048-token input with 32 chunks and two 128-token neighbors each effectively consults 8,192 retrieved tokens without placing them in the self-attention context.
The comparison below shows how CCA differs from the main alternatives for feeding retrieved text into a model.
| Integration method | Where retrieval enters | Cost profile |
|---|---|---|
| Prompt concatenation (RAG) | Input context of the decoder | Quadratic in total context length |
| Fusion-in-decoder | Decoder attends to encoded passages | Linear in passages, encoder per passage |
| Chunked cross-attention (RETRO) | Dedicated layers per chunk | Linear in retrieved chunks |
| kNN-LM interpolation | Output distribution only | Lookup at every generated token |
RETRO compared with related retrieval models
RETRO belongs to a family of retrieval-augmented language models that differ in when retrieval happens, whether the retriever is trained and how large the database can be. Its distinctive choices are a frozen retriever and a database measured in trillions of tokens, far larger than the document collections used by earlier systems.
| Model | Retriever training | Main use |
|---|---|---|
| RETRO | Frozen BERT embeddings | Language modeling at scale |
| REALM | Trained jointly with the reader | Open-domain question answering |
| RAG (original) | Dense retriever fine-tuned end to end | Knowledge-intensive generation |
| kNN-LM | Uses the model’s own hidden states | Perplexity reduction, domain adaptation |
| Atlas | Trained jointly, few-shot oriented | Question answering with few examples |
The original paper also introduced RETROfitting: adding and training only the retrieval layers on top of an existing frozen transformer. This retrofit recovered much of the benefit at a small fraction of full training cost, which suggested that retrieval can be bolted onto pretrained models rather than requiring training from scratch.
Strengths and practical use
RETRO’s central argument is that memorization can be outsourced to a database. This brings several practical benefits that matter when choosing an architecture.
- Parameter efficiency: smaller decoders reach the quality of much larger dense models.
- Updatable knowledge: the database can be edited or extended without retraining, at least in principle.
- Inspectability: retrieved neighbors show which text influenced a prediction, aiding attribution.
- Scaling with data: quality keeps improving as the database grows into the trillions of tokens.
In practice, RETRO-style models suit settings with a large, relatively stable corpus and heavy inference volume, where a smaller decoder saves compute. For rapidly changing enterprise documents, prompt-level RAG is usually simpler because it works with any off-the-shelf model.
Limitations and open questions
Part of RETRO’s reported gain came from overlap between evaluation data and the retrieval database, a form of test leakage that the authors measured and discussed openly. When overlap was filtered out, the improvement shrank but did not disappear, so the true benefit depends on how related the database is to the task.
| Limitation | Cause | Consequence |
|---|---|---|
| Test set leakage | Evaluation text present in database | Overstated perplexity gains |
| Infrastructure cost | Trillion-token index in memory | Complex serving and storage |
| Frozen retriever | Embeddings never adapt to the task | Imperfect neighbor relevance |
| Fixed chunk boundaries | 64-token segmentation | Retrieval may split related ideas |
| Limited downstream adoption | Instruction-tuned RAG proved simpler | Few production deployments |
Follow-up studies found that RETRO’s advantage on question answering was smaller than on perplexity, and that the model sometimes copied retrieved text rather than reasoning over it. These findings keep the balance between parametric and retrieved knowledge an active research topic.
The idea in brief
RETRO is a language model that looks things up while it writes. Most models must store everything they know inside their own settings. RETRO keeps a huge library of text on the side. As it writes each short piece, it fetches a few similar passages from that library and reads them.
This works like an open-book exam. A student with good notes does not need to memorize every fact. A smaller model with a large library can do as well as a much larger model that memorized everything.
A practical scenario
A research group builds a language model for scientific literature search across tens of millions of papers. A dense model large enough to memorize the field would be too expensive to serve. The group trains a 1.5-billion-parameter RETRO-style decoder and indexes about 200 billion tokens of abstracts and full texts with frozen embeddings.
When a researcher drafts a summary of protein folding methods, each 64-token chunk retrieves two closely related passages, and chunked cross-attention lets the decoder ground its wording in them. The team carefully removes evaluation papers from the database, since leakage would otherwise inflate their results.
The outcome is a model with noticeably lower perplexity on new papers than a dense baseline of similar size, and the index can be refreshed monthly as new articles appear without any retraining.