Abstract
Retrieving documents and prepending them in-context at inference time improves performance of language models (LMs) on a wide range of tasks. However, these documents, often spanning hundreds of words, make inference substantially more expensive. We propose compressing the retrieved documents into textual summaries prior to in-context integration. This not only reduces the computational costs but also relieves the burden of LMs to identify relevant information in long retrieved documents. We present two compressors—an extractive compressor which selects useful sentences from retrieved documents and an abstractive compressor which generates summaries by synthesizing information from multiple documents. Both compressors are trained to improve LMs' performance on end tasks when the generated summaries are prepended to the LMs' input, while keeping the summary concise. If the retrieved documents are irrelevant to the input or offer no additional information to the LM, our compressor can return an empty string, implementing selective augmentation. We evaluate our approach on language modeling and open-domain question answering tasks. We achieve a compression rate as low as 6% with minimal loss in performance for both tasks, significantly outperforming off-the-shelf summarization models. We show that our compressors trained for one LM can transfer to other LMs and provide summaries largely faithful to the retrieved documents.
Introduction
Retrieval-Augmented Language Models (RALMs) have become the standard for knowledge-intensive tasks, providing LMs with "open-book" capabilities by fetching relevant documents from external databases. Despite their success, RALMs face three critical bottlenecks: high computational costs due to long context lengths, the "lost in the middle" phenomenon where LMs struggle with information buried in long prompts, and the risk of distraction from irrelevant or noisy retrieved data.
RECOMP (Retrieve, Compress, Prepend) addresses these challenges by introducing a specialized compression layer that distills retrieved information into ultra-concise, task-relevant summaries before they reach the base language model.
Methodology
The core of the RECOMP framework is a compressor module situated between the retrieval step and the final LM inference. Unlike standard summarization models that aim for human-centric readability, RECOMP compressors are trained to prioritize information that maximizes the likelihood of the LM generating the correct answer.
The researchers developed two distinct compression strategies:
- Extractive Compressor: Utilizing a dual-encoder architecture based on Contriever, this model selects the most helpful sentences from the retrieved documents. It is trained using a contrastive loss where "positive" sentences are those that demonstrably help the LM solve the task.
- Abstractive Compressor: Based on the T5 encoder-decoder architecture, this model synthesizes information from multiple sources into a single summary. A key innovation here is the use of a "critic" during training. If a generated summary does not improve the base LM's performance over a zero-retrieval baseline, the target is replaced with an empty string. This teaches the model selective augmentation, allowing it to remain silent when retrieved data is unhelpful.
Evaluation and Insights
RECOMP was evaluated across two primary domains: Language Modeling (Wikitext-103) and Open-Domain Question Answering (Natural Questions, TriviaQA, and HotpotQA). The compressors were tested on various base models, including GPT-2, GPT-J (6B), and Flan-UL2 (20B).
Several key insights emerged from the study:
- Task-Awareness: Training compressors specifically for the LM's needs outperforms general-purpose summarization.
- Transferability: A compressor trained for a small model (like GPT-2) transfers effectively to much larger models (like GPT-J), suggesting that "useful information" is consistent across architectures.
- Noise Reduction: By filtering out irrelevant tokens, compressed summaries often lead to better performance than providing full, uncompressed documents, as they mitigate the distraction penalty.
Key Results
RECOMP achieved massive token savings with minimal performance impact. On the Natural Questions (NQ) dataset, the abstractive compressor reached an Exact Match (EM) score of 37.04 using only 36 tokens. In contrast, prepending five full documents required 660 tokens to achieve a slightly higher 39.39 EM—representing an 18x reduction in context length for a negligible performance hit.
As shown in the results table, RECOMP consistently outperforms off-the-shelf models like T5 or GPT-3.5 when used for compression. Furthermore, the abstractive models successfully implemented selective filtering, returning empty strings for 4% to 24% of queries, effectively acting as a quality gate for the retrieval system.
Conclusion and Limitations
RECOMP demonstrates that retrieval-augmented LMs can be made significantly more efficient without sacrificing accuracy. However, challenges remain. The abstractive compressor struggled more with multi-hop reasoning tasks like HotpotQA, where extractive methods proved more reliable. Additionally, while RECOMP is more faithful than standard models, abstractive hallucination remains a risk. Future work may explore adaptive compression lengths to further optimize the balance between conciseness and information density.
Summary updated