[Paper Review] In-Context Retrieval-Augmented Language Models
This paper shows that prepending retrieved documents to input (In-Context RALM) using off-the-shelf retrievers, especially BM25, yields large language modeling gains without changing the LM, and further gains come from LM-oriented reranking of retrieved docs.
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, without any further training of the LM. We show that In-Context RALM that builds on off-the-shelf general purpose retrievers provides surprisingly large LM gains across model sizes and diverse corpora. We also demonstrate that the document retrieval and ranking mechanism can be specialized to the RALM setting to further boost performance. We conclude that In-Context RALM has considerable potential to increase the prevalence of LM grounding, particularly in settings where a pretrained LM must be used without modification or even via API access.
Motivation & Objective
- Motivate grounding large language models (LMs) without modifying their architectures or training.
- Evaluate a simple in-context retrieval-augmented framework across diverse corpora and model sizes.
- Investigate retrieval strategies and document reranking to maximize LM performance.
- Demonstrate applicability to open-domain question answering and discuss deployment benefits.
Proposed method
- Propose In-Context RALM: prepend retrieved documents to the LM input without changing LM weights.
- Use retrieval stride s to control how often retrieval occurs during generation.
- Use retrieval query length ell to limit the portion of the prefix used for querying the retriever.
- Evaluate with multiple open-source LMs (GPT-2, GPT-Neo/J, OPT, LLaMA) across five corpora (WikiText-103, RealNews, ArXiv, Stack Exchange, FreeLaw).
- Compare sparse (BM25) vs dense retrievers; show BM25 often outperforms neural retrievers in zero-shot settings.
- Introduce two LM-oriented reranking methods: (a) zero-shot reranking using an LM, (b) predictive reranking trained on domain data to select the best top-k docs.
- Evaluate open-domain QA performance using Natural Questions and TriviaQA.
Experimental results
Research questions
- RQ1How much can LM performance improve by simply prepending retrieved documents to the input of an off-the-shelf LM?
- RQ2Which retriever type and retrieval configuration (stride and query length) maximize in-context grounding for language modeling?
- RQ3Can LM-oriented reranking of retrieved documents yield further gains beyond naive top-1 retrieval?
- RQ4How well does In-Context RALM transfer to open-domain QA tasks without LM modification or fine-tuning?
Key findings
- BM25 retriever often outperforms dense neural retrievers for in-context LM grounding.
- Frequent retrieval (smaller stride s) yields stronger perplexity gains than sparse retrieval, with s = 4 as a practical default.
- A retrieval query length around ell = 32 tokens is a sweet spot for BM25 in this setting.
- In-Context RALM with an off-the-shelf retriever can match the performance of 2–3× larger models across corpora.
- LM-oriented reranking (zero-shot) and predictive reranking provide additional perplexity reductions beyond vanilla BM25, with predictive reranking trained on domain data giving notable gains.
- For large models, In-Context RALM can elevate the performance of much smaller models to match much larger ones (e.g., 6.7B OPT model with BM25 can rival 66B OPT in some settings).
- In open-domain QA, providing retrieved documents as context substantially improves performance, even with a frozen LM; two documents often suffice.
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.