IN THIS BREAKDOWN · 10 SECTIONS
You can read 23% of this breakdown.
The paper in one minute
RETRO (Retrieval-Enhanced Transformer) adds a lookup step to an autoregressive language model. The input is split into chunks of 64 tokens. For each chunk, the model retrieves its k nearest neighbors from a database, where each entry is a 64-token chunk plus the 64 tokens that followed it in the original document. Similarity is the distance between frozen BERT embeddings of the chunks, searched approximately with ScaNN, which the authors say takes about 10 ms over a 2-trillion-token database.
The retrieved text goes through a small transformer encoder, and the main model attends to it with chunked cross-attention: tokens in chunk u+1 can attend to the neighbors retrieved for chunk u, which keeps the model autoregressive. Cross-attention layers are inserted every third block. Because BERT is frozen, all neighbors for the training data can be computed in advance.
Training uses DeepMind's multilingual MassiveText data; during training the model retrieves from a 600-billion-token subset, and at evaluation from 1.75 trillion tokens. Models range from 172M to 7.5B parameters, about 8% to 30% more than matching baselines.
The gains are large and consistent. Retrieval improves every dataset in the main scaling comparison at every model size, by roughly what a 10 times larger model would give, and keeps improving as the database grows and as more neighbors are retrieved (up to about 40). On the Pile, the 7.5B RETRO beats Jurassic-1 (178B) and Gopher (280B) on most subsets. An existing transformer can be "retrofitted" by training only the new cross-attention and encoder weights on 3% of the original data.
The authors also take test leakage seriously. Because the model can copy from its database, they measure how much evaluation text overlaps database chunks and show results as a function of that overlap. Retrieval helps even on chunks with little overlap, but much of the most dramatic result, on Wikitext103, comes from overlap.
Research notes: the problem, approach and results
parameter increase that retrieval's gain resembles, roughly constant from 172M to 7.5B parameters (Figure 1)
Wikitext103 test perplexity, baseline vs RETRO with the full database; 'partly due to' overlap deduplication missed (Table 4)
fewer bytes stored per database token than token-level kNN-LM, because one key covers a 64-token chunk (our calculation)
Language models get better by growing, which raises training and serving cost, and their knowledge is fixed at training time. Can a smaller model get the same quality by looking things up in a very large text database while it predicts?
Split the input into 64-token chunks. For each chunk, retrieve similar chunks and their continuations from a 2-trillion-token database using frozen BERT embeddings and approximate nearest-neighbor search, and let the model attend to them through a chunked cross-attention layer built into the transformer.
A 7.5B-parameter RETRO model matched or beat 178B and 280B models on most Pile subsets, and retrieval gave gains similar to a 10 times larger model across sizes from 172M to 7.5B. Gains grew with database size. Much of the dramatic Wikitext103 result came from evaluation text present in the database.
Why it matters to an FDE
Retrieval can stand in for model size. The central result is that a small model with a large, relevant database can match much larger models on knowledge-heavy text. For customers, this is the argument for retrieval-augmented systems over ever-larger models: knowledge lives in a database that can be updated, filtered and audited.
Index at the chunk level. RETRO stores one key per 64-token chunk, not per token. That is why it could index trillions of tokens; token-level kNN-LM would need about 4 KB per token. The same arithmetic applies to customer vector indexes: chunk size sets the index size, the retrieval granularity and the cost.
Check evaluation sets against the index. A retrieval model can copy evaluation text if it is in the database. RETRO's Wikitext103 perplexity drops from 22.96 to 3.92 with the full database, and the authors attribute this partly to overlap that their deduplication missed. When a customer's RAG system scores very well on a test set, check whether the test documents, or near copies, are in the index.
Measure with a leakage filter. The paper's method is reusable: for each evaluation chunk, find the longest run of tokens it shares with its retrieved neighbors, and report results separately for chunks with low overlap. That separates "found the answer" from "found the test".
Know what RETRO is not. It is retrieval built into pretraining, with a custom architecture. Most production RAG puts retrieved text into the prompt of an off-the-shelf model. RETRO's lessons transfer (scaling the database, chunk granularity, leakage), the architecture usually does not.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 290 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
Architecture, database, scaling, retrofitting, question answering, leakage, two misreadings
Free account - 04How it works
Database layout, retrieval, the encoder and cross-attention, training data, and the leakage metric
Premium - 05The numbers that matter
Wikitext103 by database, storage, Pile comparisons, QA scores, retrofitting and model sizes
Premium - 06Try it yourself
Check index arithmetic, read Table 4 in bits per token, run the overlap filter, check ratios
Premium - 07Where it breaks
Leakage in headline numbers, custom architecture, private data, QA behind FiD, filter gaps
Premium - 08Using it on a deployment
Database scale, chunk granularity, leakage checks for RAG evaluations, updatable knowledge
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
