[Paper Review] Retrieval-Pretrained Transformer: Long-range Language Modeling with Self-retrieval
The Retrieval-Pretrained Transformer (RPT) is a retrieval-augmented language model trained from scratch with a jointly optimized retriever that uses self-retrieval to fetch semantically relevant past chunks for long-context generation. By training the retriever via a semantic objective that maximizes the likelihood of next-token prediction using a reference LM, RPT achieves state-of-the-art perplexity across four long-form tasks—books, code, and mathematical writing—outperforming strong baselines while improving retrieval quality.
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 post-hoc 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 and apply it to 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 before. Information from retrieved chunks is fused into the LM representations to predict the next target chunk. We train the retriever component with a semantic objective, where the goal is to retrieve chunks that increase the probability of the next chunk, according to a reference LM. We evaluate RPT on four long-range language modeling tasks, spanning books, code, and mathematical writing, and demonstrate that RPT improves retrieval quality and subsequently perplexity across the board compared to strong baselines.
Motivation & Objective
- To address the limitation of existing retrieval-augmented language models (RALMs) that treat the retriever as an external or fixed component, not jointly trained with the language model.
- To enable joint training of the retriever and language model from scratch, allowing mutual adaptation and improved long-context modeling.
- To improve long-range language modeling by retrieving semantically relevant past text chunks using query representations derived from the model's own hidden states (self-retrieval).
- To train the retriever with a semantic objective that encourages retrieval of chunks increasing the probability of the next target chunk, using a reference scoring LM as supervision.
- To demonstrate that end-to-end training with semantic retrieval leads to better performance and higher-quality retrieval than lexical or fixed-retriever baselines.
Proposed method
- RPT uses self-retrieval: query representations for retrieval are derived directly from the decoder’s hidden states of the recently generated text chunk.
- The retriever retrieves semantically relevant past chunks from the document, potentially tens of thousands of tokens prior, using a dense vector similarity mechanism.
- Retrieved representations are fused into the decoder via chunked cross-attention, enabling contextualized integration of long-range information.
- The retriever is trained with an auxiliary loss that maximizes the probability of the next target chunk given the retrieved and current context, using a reference LM as a scoring function.
- The training objective combines standard language modeling loss with a retrieval-specific loss that aligns retrieval with downstream generation performance.
- The entire architecture is trained from scratch, without pre-training on external data, and the retriever index is computed via a forward pass, avoiding test-time index updates.

Experimental results
Research questions
- RQ1Can a retrieval-augmented language model achieve better long-context performance when the retriever is jointly trained from scratch with the language model, rather than added post-pretraining?
- RQ2Does self-retrieval—using the model’s own representations to query past content—improve retrieval quality and generation performance in long-form text?
- RQ3Can a semantic retrieval objective, trained to maximize the likelihood of the next token given retrieved context, outperform lexical or fixed-retriever baselines?
- RQ4How does RPT compare to strong baselines like CCA, TRIME, and RETRO in terms of perplexity and retrieval quality across diverse long-form tasks?
- RQ5Can a retriever trained from scratch with a semantic objective surpass lexical retrieval methods like BM25 without any pre-training?
Key findings
- RPT achieves state-of-the-art perplexity across four long-range language modeling tasks: books, code, mathematical writing, and dialogue, outperforming strong baselines including CCA and TRIME.
- The retriever in RPT retrieves higher-quality, semantically relevant chunks compared to lexical baselines like BM25, as evidenced by improved next-token prediction likelihood.
- Joint training from scratch enables the retriever and language model to adapt to each other, leading to better performance than models with fixed or separately pre-trained retrievers.
- The semantic retrieval objective, which optimizes for next-token likelihood via a reference LM, results in more effective retrieval than lexical or heuristic supervision.
- RPT demonstrates that end-to-end training with self-retrieval and semantic supervision can surpass models relying on pre-trained retrievers or test-time-only retrieval.
- The model shows consistent improvements in both perplexity and retrieval quality across diverse domains, suggesting broad applicability to long-form generation tasks.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.