Improving language models by retrieving from trillions of tokens

Authors: Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, Diego de Las Casas, Aurelia Guy, Jacob Menick, Roman Ring, Tom Hennigan, Saffron Huang, Loren Maggiore, Chris Jones, Albin Cassirer, Andy Brock, Michela Paganini, Geoffrey Irving, Oriol Vinyals, Simon Osindero, Karen Simonyan, Jack W. Rae, Erich Elsen, Laurent Sifre

Submitted to arXiv on 08 Dec. 2021
License: CC BY 4.0
Abstract

We enhance auto-regressive language models by conditioning on document chunks retrieved from a large corpus, based on local similarity with preceding tokens. With a $2$ trillion token database, our Retrieval-Enhanced Transformer (RETRO) obtains comparable performance to GPT-3 and Jurassic-1 on the Pile, despite using 25$\times$ fewer parameters. After fine-tuning, RETRO performance translates to downstream knowledge-intensive tasks such as question answering. RETRO combines a frozen Bert retriever, a differentiable encoder and a chunked cross-attention mechanism to predict tokens based on an order of magnitude more data than what is typically consumed during training. We typically train RETRO from scratch, yet can also rapidly RETROfit pre-trained transformers with retrieval and still achieve good performance. Our work opens up new avenues for improving language models through explicit memory at unprecedented scale.

The papers around it, by date and closeness

Higher is closer to this paper; left is older. Lines join papers close to each other: groups of lines are sub-topics. Select a point to see why it is there. Back to the summary of this paper

How to read this map? Illustrated guide

Closest papers Prior work it builds on Papers that cite it

Papers around this one

Ranked by how close their title and abstract are to this paper’s. Select some to read them together.

Closest papers

  1. Very close Broader context
    Scaling Transformer to 1M tokens and beyond with RMT
    Aydar Bulatov, Yuri Kuratov, Mikhail S. Burtsev · 2023 · Computation and Language · preprint, not peer reviewed · cited 119 times · AI summary available

    Scaling Transformer to 1M tokens and beyond with RMT uses recurrent memory to extend BERT's context, rather than retrieving external corpus chunks to condition language modeling.

    Abstract

    This technical report presents the application of a recurrent memory to extend the context length of BERT, one of the most effective Transformer-based models in natural language processing. By leveraging the Recurrent Memory Transformer architecture, we have successfully increased the model's effective context length to an unprecedented two million tokens, while maintaining high memory retrieval accuracy. Our method allows for the storage and processing of both local and global information and enables information flow between segments of the input sequence through the use of recurrence. Our experiments demonstrate the effectiveness of our approach, which holds significant potential to enhanc…

  2. Close Another approach to the problem
    Long-range Language Modeling with Self-retrieval
    Ohad Rubin, Jonathan Berant · 2023 · Computation and Language · cited 34 times · AI summary available

    Long-range Language Modeling with Self-retrieval jointly trains a model to retrieve earlier chunks within a document, whereas RETRO retrieves chunks from a large corpus.

    Abstract

    Retrieval-augmented language models (LMs) have received much attention recently. However, typically the retriever is not trained jointly as a native component of the LM, but added to an already-pretrained LM, which limits the ability of the LM and the retriever to adapt to one another. In this work, we propose the Retrieval-Pretrained Transformer (RPT), an architecture and training procedure for jointly training a retrieval-augmented LM from scratch for the task of modeling long texts. Given a recently generated text chunk in a long document, the LM computes query representations, which are then used to retrieve earlier chunks in the document, located potentially tens of thousands of tokens …

  3. Close Broader context
    Retentive Network: A Successor to Transformer for Large Language Models
    Yutao Sun, Li Dong, Shaohan Huang et al. · 2023 · Computation and Language · preprint, not peer reviewed · cited 833 times · AI summary available

    Retentive Network proposes recurrent retention for efficient sequence modeling, not RETRO's external retrieval and cross-attention over corpus chunks.

    Abstract

    In this work, we propose Retentive Network (RetNet) as a foundation architecture for large language models, simultaneously achieving training parallelism, low-cost inference, and good performance. We theoretically derive the connection between recurrence and attention. Then we propose the retention mechanism for sequence modeling, which supports three computation paradigms, i.e., parallel, recurrent, and chunkwise recurrent. Specifically, the parallel representation allows for training parallelism. The recurrent representation enables low-cost $O(1)$ inference, which improves decoding throughput, latency, and GPU memory without sacrificing performance. The chunkwise recurrent representation …

  4. Close Another approach to the problem
    RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval
    Parth Sarthi, Salman Abdullah, Aditi Tuli et al. · 2024 · Computation and Language · cited 854 times · AI summary available

    RAPTOR retrieves recursively summarized document chunks from a tree, while RETRO retrieves locally similar chunks from a corpus.

    Abstract

    Retrieval-augmented language models can better adapt to changes in world state and incorporate long-tail knowledge. However, most existing methods retrieve only short contiguous chunks from a retrieval corpus, limiting holistic understanding of the overall document context. We introduce the novel approach of recursively embedding, clustering, and summarizing chunks of text, constructing a tree with differing levels of summarization from the bottom up. At inference time, our RAPTOR model retrieves from this tree, integrating information across lengthy documents at different levels of abstraction. Controlled experiments show that retrieval with recursive summaries offers significant improvemen…

  5. Close Another approach to the problem
    REPLUG: Retrieval-Augmented Black-Box Language Models
    Weijia Shi, Sewon Min, Michihiro Yasunaga et al. · 2023 · Computation and Language · cited 1,174 times · Not summarized yet

    REPLUG prepends retrieved documents to a frozen black-box language model, unlike RETRO's differentiable encoder and chunked cross-attention.

    Abstract

    We introduce REPLUG, a retrieval-augmented language modeling framework that treats the language model (LM) as a black box and augments it with a tuneable retrieval model. Unlike prior retrieval-augmented LMs that train language models with special cross attention mechanisms to encode the retrieved text, REPLUG simply prepends retrieved documents to the input for the frozen black-box LM. This simple design can be easily applied to any existing retrieval and language models. Furthermore, we show that the LM can be used to supervise the retrieval model, which can then find documents that help the LM make better predictions. Our experiments demonstrate that REPLUG with the tuned retriever signif…

  6. Close Broader context
    Mass-Editing Memory in a Transformer
    Kevin Meng, Arnab Sen Sharma, Alex Andonian et al. · 2022 · Computation and Language · cited 1,335 times · AI summary available

    Mass-Editing Memory in a Transformer updates many factual associations inside model weights, while RETRO supplies external memory through retrieval.

    Abstract

    Recent work has shown exciting promise in updating large language models with new memories, so as to replace obsolete information or add specialized knowledge. However, this line of work is predominantly limited to updating single associations. We develop MEMIT, a method for directly updating a language model with many memories, demonstrating experimentally that it can scale up to thousands of associations for GPT-J (6B) and GPT-NeoX (20B), exceeding prior work by orders of magnitude. Our code and data are at https://memit.baulab.info.

  7. Close Broader context
    Learning to Recall with Transformers Beyond Orthogonal Embeddings
    Nuri Mert Vural, Alberto Bietti, Mahdi Soltanolkotabi et al. · 2026 · International Conference on Learning Representations · cited 1 time · Not summarized yet

    Learning to Recall with Transformers Beyond Orthogonal Embeddings theoretically analyzes token retrieval in a single-layer transformer, rather than retrieval-augmented language modeling.

    Abstract

    Modern large language models (LLMs) excel at tasks that require storing and retrieving knowledge, such as factual recall and question answering. Transformers are central to this capability because they can encode information during training and retrieve it at inference. Existing theoretical analyses typically study transformers under idealized assumptions such as infinite data or orthogonal embeddings. In realistic settings, however, models are trained on finite datasets with non-orthogonal (random) embeddings. We address this gap by analyzing a single-layer transformer with random embeddings trained with (empirical) gradient descent on a simple token-retrieval task, where the model must ide…

  8. Close Broader context
    Accelerating Large Language Model Pretraining via LFR Pedagogy: Learn, Focus, and Review
    Neha Prakriya, Jui-Nan Yen, Cho-Jui Hsieh et al. · 2024 · Computation and Language · cited 2 times · Not summarized yet

    Accelerating Large Language Model Pretraining via LFR Pedagogy repeatedly reviews difficult training data, rather than retrieving corpus chunks during generation.

    Abstract

    Large Language Model (LLM) pretraining traditionally relies on autoregressive language modeling on randomly sampled data blocks from web-scale datasets. We take inspiration from human learning techniques like spaced repetition to hypothesize that random data sampling for LLMs leads to high training cost and low quality models which tend to forget data. In order to effectively commit web-scale information to long-term memory, we propose the LFR (Learn, Focus, and Review) pedagogy, a new dynamic training paradigm which focuses and repeatedly reviews complex data blocks at systematic intervals based on the model's learning pace and progress. LFR records the model perplexities for different data…

Prior work it builds on

  1. Close Groundwork for this paper Used in depth by this paper
    Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
    Patrick Lewis, Ethan Perez, Aleksandra Piktus et al. · 2020 · Computation and Language · cited 20,707 times · AI summary available

    Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks conditions generation on retrieved documents for knowledge-intensive tasks, a foundation for RETRO's retrieval-augmented modeling.

    Abstract

    Large pre-trained language models have been shown to store factual knowledge in their parameters, and achieve state-of-the-art results when fine-tuned on downstream NLP tasks. However, their ability to access and precisely manipulate knowledge is still limited, and hence on knowledge-intensive tasks, their performance lags behind task-specific architectures. Additionally, providing provenance for their decisions and updating their world knowledge remain open research problems. Pre-trained models with a differentiable access mechanism to explicit non-parametric memory can overcome this issue, but have so far been only investigated for extractive downstream tasks. We explore a general-purpose …

  2. Related Broader context Used in depth by this paper A method it uses
    Scaling Language Models: Methods, Analysis & Insights from Training Gopher
    Jack W. Rae, Sebastian Borgeaud, Trevor Cai et al. · 2021 · arXiv.org · preprint, not peer reviewed · cited 1,697 times · AI summary available

    Scaling Language Models analyzes language-model performance across model sizes and tasks, while RETRO focuses on retrieval as a way to improve language modeling.

    Abstract

    Language modelling provides a step towards intelligent communication systems by harnessing large repositories of written human knowledge to better predict and understand the world. In this paper, we present an analysis of Transformer-based language model performance across a wide range of model scales -- from models with tens of millions of parameters up to a 280 billion parameter model called Gopher. These models are evaluated on 152 diverse tasks, achieving state-of-the-art performance across the majority. Gains from scale are largest in areas such as reading comprehension, fact-checking, and the identification of toxic language, but logical and mathematical reasoning see less benefit. We …

  3. Close Groundwork for this paper A method it uses
    Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
    Zihang Dai, Zhilin Yang, Yiming Yang et al. · 2019 · Machine Learning · cited 4,643 times · AI summary available

    Transformer-XL uses segment recurrence to model dependencies beyond a fixed context, an earlier approach to extending language-model context.

    Abstract

    Transformer networks have a potential of learning longer-term dependency, but are limited by a fixed-length context in the setting of language modeling. As a solution, we propose a novel neural architecture, \textit{Transformer-XL}, that enables Transformer to learn dependency beyond a fixed length without disrupting temporal coherence. Concretely, it consists of a segment-level recurrence mechanism and a novel positional encoding scheme. Our method not only enables capturing longer-term dependency, but also resolves the problem of context fragmentation. As a result, Transformer-XL learns dependency that is about 80\% longer than RNNs and 450\% longer than vanilla Transformers, achieves bett…

  4. Close Groundwork for this paper
    REALM: Retrieval-Augmented Language Model Pre-Training
    Kelvin Guu, Kenton Lee, Zora Tung et al. · 2020 · International Conference on Machine Learning · cited 3,619 times · Not summarized yet

    REALM augments language-model pretraining with a document retriever and attention over external knowledge, an earlier retrieval-augmented approach.

    Abstract

    Language model pre-training has been shown to capture a surprising amount of world knowledge, crucial for NLP tasks such as question answering. However, this knowledge is stored implicitly in the parameters of a neural network, requiring ever-larger networks to cover more facts. To capture knowledge in a more modular and interpretable way, we augment language model pre-training with a latent knowledge retriever, which allows the model to retrieve and attend over documents from a large corpus such as Wikipedia, used during pre-training, fine-tuning and inference. For the first time, we show how to pre-train such a knowledge retriever in an unsupervised manner, using masked language modeling a…

  5. Related Groundwork for this paper Used in depth by this paper A method it uses
    Leveraging Passage Retrieval with Generative Models for Open Domain Question Answering
    Gautier Izacard, E. Grave · 2020 · Conference of the European Chapter of the Association for Computational Linguistics · cited 2,230 times · AI summary available

    Leveraging Passage Retrieval with Generative Models studies retrieving evidence passages for open-domain question answering, an earlier use of retrieval with generative models.

    Abstract

    Generative models for open domain question answering have proven to be competitive, without resorting to external knowledge. While promising, this approach requires to use models with billions of parameters, which are expensive to train and query. In this paper, we investigate how much these models can benefit from retrieving text passages, potentially containing evidence. We obtain state-of-the-art results on the Natural Questions and TriviaQA open benchmarks. Interestingly, we observe that the performance of this method significantly improves when increasing the number of retrieved passages. This is evidence that sequence-to-sequence models offers a flexible framework to efficiently aggreg…

Papers that cite it

  1. Close Broader context
    Benchmarking Large Language Models in Retrieval-Augmented Generation
    Jiawei Chen, Hongyu Lin, Xianpei Han et al. · 2024 · Proceedings of the AAAI Conference on Artificial Intelligence · cited 547 times · AI summary available

    Benchmarking Large Language Models in Retrieval-Augmented Generation evaluates RAG abilities across models, rather than proposing RETRO's retrieval-based language-model architecture.

    Abstract

    Retrieval-Augmented Generation (RAG) is a promising approach for mitigating the hallucination of large language models (LLMs). However, existing research lacks rigorous evaluation of the impact of retrieval-augmented generation on different large language models, which make it challenging to identify the potential bottlenecks in the capabilities of RAG for different LLMs. In this paper, we systematically investigate the impact of Retrieval-Augmented Generation on large language models. We analyze the performance of different large language models in 4 fundamental abilities required for RAG, including noise robustness, negative rejection, information integration, and counterfactual robustness…

  2. Close Broader context Uses this paper in depth
    TF-Engram: A Train-Free Engram with SSD-Backed Memory for Large Language Models
    Yu-Tang Ma, Ke-Cheng Huang, Xi-Kun Jiang et al. · 2026 · arXiv.org · preprint, not peer reviewed · cited 3 times · Not summarized yet

    TF-Engram stores phrase-specific external memory across GPU, DRAM, and SSD for hidden-state injection, unlike RETRO's retrieved chunks and cross-attention.

    Abstract

    Large Language Models (LLMs) store factual knowledge and domain-specific patterns implicitly in dense Transformer parameters, making knowledge expansion costly through pretraining, fine-tuning, retrieval augmentation, or longer contexts. Engram-style memory offers a compact hidden-state injection pathway, but existing GPU-resident designs often rely on hash-based compression, causing unrelated phrases to collide in shared slots and weakening phrase-level semantic fidelity. We present TF-Engram, a train-free Engram system that constructs phrase-specific semantic memory offline from external corpora, stores large memory tables across a GPU--DRAM--SSD hierarchy, and uses Early-Exit Guided Predi…

  3. Related Broader context Uses this paper in depth
    Retrievable Gradients: Continual Post-Training Without Cumulative Weight Drift
    Wei-Hang Su, Ji-Hun Kang, Jing-Yan Xu et al. · 2026 · Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing · Not summarized yet

    Retrievable Gradients retrieves document-specific gradients for temporary model adaptation, rather than retrieved text chunks for token prediction.

    Abstract

    Continual post-training enables models to absorb emerging knowledge after deployment, but repeatedly updating shared parameters can accumulate weight drift, potentially causing catastrophic forgetting and degrading general capabilities. Retrieval-augmented generation avoids such parameter drift, yet often lacks the depth of parametric knowledge integration. In this paper, we propose ReGrad (Retrievable Gradients), a new paradigm that treats gradients as retrievable units of knowledge. ReGrad pre-computes document-specific gradients offline, stores them in an indexed Gradient Bank, and retrieves only query-relevant gradients at inference time for temporary weight adaptation. However, raw lang…

  4. Close Broader context
    δ-mem: Efficient Online Memory for Large Language Models
    Jing-Di Lei, Di Zhang, Junxian Li et al. · 2026 · arXiv.org · preprint, not peer reviewed · cited 15 times · Not summarized yet

    δ-mem stores past information in a compact online associative state, unlike RETRO's retrieval from a large external corpus.

    Abstract

    Large language models increasingly need to accumulate and reuse historical information in long-term assistants and agent systems. Simply expanding the context window is costly and often fails to ensure effective context utilization. We propose $\delta$-mem, a lightweight memory mechanism that augments a frozen full-attention backbone with a compact online state of associative memory. $\delta$-mem compresses past information into a fixed-size state matrix updated by delta-rule learning, and uses its readout to generate low-rank corrections to the backbone's attention computation during generation. With only an $8\times8$ online memory state, $\delta$-mem improves the average score to $1.10\ti…

  5. Related Builds on this paper
    In-Context Retrieval-Augmented Language Models
    Ori Ram, Yoav Levine, Itay Dalmedigos et al. · 2023 · Transactions of the Association for Computational Linguistics · cited 549 times · AI summary available

    In-Context Retrieval-Augmented Language Models cites RETRO and instead augments an unchanged language model by prepending retrieved documents.

    Abstract

    Abstract Retrieval-Augmented Language Modeling (RALM) methods, which condition a language model (LM) on relevant documents from a grounding corpus during generation, were shown to significantly improve language modeling performance. In addition, they can mitigate the problem of factually inaccurate text generation and provide natural source attribution mechanism. Existing RALM approaches focus on modifying the LM architecture in order to facilitate the incorporation of external information, significantly complicating deployment. This paper considers a simple alternative, which we dub In-Context RALM: leaving the LM architecture unchanged and prepending grounding documents to the input, witho…

How are these papers found?

We compare the title and abstract of this paper with those of every paper summarized on this site, and with the papers Semantic Scholar recommends, those it cites and those citing it (for a much-cited paper, its most recent citations and, from OpenAlex, the most cited ones). Among the prior work and the follow-ups, the papers that use each other in depth, a method it uses and the much-cited follow-ups come a little higher. The levels (very close, close, related) come from the similarity of the texts, not from a judgment of quality; * marks a paper without an abstract, compared by its title. The sentence under a paper is written by an AI from the two abstracts: check it in the papers. A paper marked not relevant by three readers leaves the list.

Updated on 5 November 2026.

The illustrated guide to the papers around a paper