More room for language: Investigating the effect of retrieval on language models (2024)

Abstract: Retrieval-augmented language models pose a promising alternative to standard language modeling. During pretraining, these models search in a corpus of documents for contextually relevant information that could aid the language modeling objective. We introduce an ‘ideal retrieval’ methodology to study these models in a fully controllable setting. We conduct an extensive evaluation to examine how retrieval augmentation affects the behavior of the underlying language model. Among other things, we observe that these models: (i) save substantially less world knowledge in their weights, (ii) are better at understanding local context and inter-word dependencies, but (iii) are worse at comprehending global context.

## introduction retrieval-augmented language models combine the strengths of self-supervised pretraining with information retrieval techniques to allow for information extraction from a nonparametric memory. during pretraining, the prediction of masked tokens is conditioned not only on the immediate context but also on information found to be contextually relevant by a similarity search over a knowledge database. these models are typically proven effective in knowledge-intensive tasks, such as answering open-domain questions @xcite @xcite . however, little emphasis has been put into understanding what this type of training scheme does to the underlying language model when analyzed as a standalone -separated from the overall retrieval pipeline. retrieval augmentation is often proposed as a better alternative to standard pretraining, without much evidence of its advantages and disadvantages. the behavior of the entire pipeline depends on the qualities of the retrieved database and the qualities of the standalone language model. while the database is relatively easy to control, the figure 1 : the aggregated absolute differences from the baseline across three categories of benchmarks, the models exhibit consistent differences for each category. in total, we evaluate the effect of retrieval on 9 language models with 8 sets of zero-shot, probing and finetuning tasks to empirically show that: from-scratch pretraining most current retrieval-augmented models are created by finetuning or continual training (retrofitting) of an already pretrained model. as shown in @xcite , only retro trains a retrieval-augmented model from scratch. while @xcite focus on improving the perplexity and text generation with retrieval assistance, we want to look at whether pretraining with retrieval leads to models having better syntactic understanding while retaining less world knowledge. this builds on the intuition that retrieval should free up parameter space for linguistic knowledge, as the relevant world-knowledge information is continuously supplied in the retrieved input. this hypothesis can be tested only by pretraining a blank model from scratch. ## controlled retrieval augmentation this study examines the general implications of retrieval augmentation in language modeling, in a fully controllable 'laboratory' setting and without relying on a particular retrieval model or parameters. all existing retrieval models are noisy (not always retrieving relevant context) and the noise might not only have a large impact on the downstream performance but also it is hard to measure and control. therefore, we use an impractical, foot_0 but fully controllable, perfect retrieval in the form of paraphrased inputs, as illustrated in figure 2 . our goal is to study the effect of retrieval augmentation on the stand-alone language model, and this setup allows us to separate the effect of retrieval type, retrieval accuracy or frequency of retrieved duplicates. as discussed later, we also provide the results of retrieval augmentation with a controlled amount of noise to get closer to a realistic scenario. simplified retrieval-augmented lm we base our experiments on masked language models as they offer greater flexibility for evaluation @xcite . the retrieval augmentation is substantially simplified thanks to paraphrase-based pretraining. as a whole, the model is an encoder-decoder transformer @xcite , where the encoder embeds the retrieved context and the decoder is a language model (figure 2 ). specifically, the decoder is given masked text segments, its training objective is to unmask it @xcite and the encoder is provided with a paraphrase of the unmasked segment. paraphrased training data we utilize the english wikipedia as a clean and information-rich text corpus. due to the cost of paraphrasing, we select only the top 10% most visited articles by page view count in the last year (about 400 million words). the paraphrases are generated by a prompted instruction-tuned mistral 7b language model @xcite , as described in appendix a. 2 quality of paraphrases it is essential to train the models on good paraphrases to avoid retrieval of irrelevant context and unwanted data leakage. for this study, a good paraphrase should have the same meaning as the original but be completely different lexically and syntactically. in that way, the retrieval can provide relevant context and world knowledge without inhibiting the training signal by allowing the model to simply copy the paraphrased document word-by-word. firstly, we utilize deep contextualized sentence embeddings to measure the preservation of meaning as the average semantic similarity of every figure 2: illustration of the full evaluation process. 1 pretraining of a retrieval-augmented language model, using an encoder-decoder transformer architecture. the retrieval mechanism is greatly simplified with paraphrase-based retrieval augmentation. the language model learns to recover a partially masked text while having access to its unmasked but paraphrased version. 2 to evaluate the standalone language model (in blue), we have to remove the retrieval augmentation (in red) and replace the cross-attention module with a simple linear projection (in purple). ## evaluation the experiments in this section evaluate how retrieval augmentation, size and retrieval quality affect world knowledge, syntactic knowledge and language understanding of language models. ## discussion retrieval augmentation separates linguistic knowledge from world knowledge there is a clear trend in the evaluated performance between the world knowledge tasks and the linguistic tasks -when a language model can rely more on retrieval during pretraining (with decreased retrieval noise), it remembers fewer facts and gets progressively worse on all evaluated world knowledge tasks; but, on the other hand, its syntactic understanding consistently improves ( the positive results on syntactic tasks suggest that retrieval-based pretraining can be a promising avenue for efficient language modeling, as far as the goal is to train a small model that understands syntax well. another notable finding is that the linguistic advantages of retrieval-pretrained models over standard models grow with the size of these models ( retrieval augmentation negatively impacts nlu performance contrary to the mostly local syntactic understanding, language understanding gets worse with retrieval-augmented pretraining ( we argue that this is in part caused by the lack of factual knowledge (which can help to resolve ambiguous cases), but that it is also indirectly caused by the way retrieval-augmented pretraining works. when searching for the global context, the language model is incentivized to trust the retrieved document more than the partially masked input, which pushes the mechanism of long-range resolution out of the language model itself. we further investigate this in an additional experiment in appendix e, where we also utilize the retriever augmentation during evaluation -this setting clearly improves the performance of long-range context resolution on lambada, which suggests that the processing of global context is mainly delegated out of the language model itself to its retrieval augmentation. this behavior poses a challenge to using retrieval augmentation for pretraining general-purpose language models. it makes retrieval finetuning (as opposed to full pretraining) not only less costly but also a more performant alternative. poor retrieval quality does not negatively impact pretraining noisy retrieval pretraining does not lead to an overall drop in performance; instead, it interpolates the behavior of standard pretraining and of pretraining with a perfect retrieval ( while a high-quality retrieval mechanism is critical during inference, our results could suggest that a subpar (but computationally inexpensive) retrieval during training does not negatively impact the overall performance. ## conclusion we introduced a novel theoretical framework for studying the properties of retrieval-augmented language models. specifically, through this paper, we were able to show that using retrieval during pretraining leads models to learn less world knowledge while gaining better syntactic knowledge; this separation is especially pronounced for larger models. however, this improvement comes at the cost of performance in general language understanding and in resolving long-range context dependency. due to the model relying on the retrieved spans, the global context resolution seems to be delegated to the retrieval module. we also performed an ablation on the effect of noisy retrieval and saw that it only slightly affects the syntactic capabilities of the model while substantially improving both its language understanding skills and world knowledge. we make all resources used in the paper openly available at https://github.com/ ltgoslo/more-room-for-language .