Introduction
Large Language Models (LLMs) are increasingly deployed in scenarios requiring massive contexts, such as Retrieval-Augmented Generation (RAG) or many-shot In-Context Learning. However, processing long contexts is computationally expensive and often leads to the "lost-in-the-middle" phenomenon, where models fail to retrieve relevant information from the center of a long prompt.
Existing prompt compression techniques often suffer from two primary issues: local context blindness, where segments are pruned independently without global awareness, and the label bottleneck, where training requires expensive "gold" compressed prompts from models like GPT-4. To address these, we present R2C (Reading To Compressing), a method that repurposes the Fusion-in-Decoder (FiD) architecture to compress prompts by up to 80% while maintaining or even enhancing LLM performance.
Methodology: The R2C Framework
R2C leverages the inherent "reading" capabilities of a multi-document reader to perform compression. It utilizes the Fusion-in-Decoder (FiD) architecture, which encodes documents separately but processes them collectively in the decoder. The core innovation lies in using the cross-attention scores from the FiD decoder as a proxy for information importance. Since the decoder is trained to synthesize answers across multiple documents, its attention naturally identifies the most salient content.
The R2C process operates in a hierarchical, coarse-to-fine manner:
- Chunk-level Compression: Irrelevant documents or paragraphs are identified and removed entirely.
- Sentence-level Compression: Within the remaining chunks, sentences are ranked and pruned based on their average attention scores.
Notably, R2C is training-free for the compression task itself; it simply utilizes the weights of a model already trained for standard question-answering (QA) tasks. By computing cross-attention scores only for the first generated token, R2C avoids the high cost of full auto-regressive generation.
Experimental Setup
The effectiveness of R2C was evaluated across two regimes:
- In-domain: Using the Natural Questions (NQ) dataset, requiring the model to find answers within 20 retrieved passages.
- Out-of-domain (Generalization): Using the LongBench benchmark, which spans five task types: Single-document QA, Multi-document QA, Summarization, Few-shot learning, and Code completion.
Key Results and Insights
R2C demonstrates significant improvements in both efficiency and accuracy. On out-of-domain tasks, it improved LLM performance by 6% compared to state-of-the-art baselines while reducing prompt length by 80%.
Efficiency and Speed
R2C is remarkably efficient, achieving up to 14.5x faster compression than methods like LongLLMLingua. When considering end-to-end inference, R2C reduced total latency by 26%. This speed is largely due to the "first-token" attention mapping strategy.
Superiority over Synthetic Labels
Interestingly, R2C outperformed RECOMP—a method that uses GPT-4 generated labels—by 5.6% on GPT-3.5 and 11.1% on Llama-2-7B. This suggests that the internal attention mechanisms of a specialized QA model are more reliable indicators of salience than the outputs of general-purpose LLMs.
Structural Integrity
Unlike token-level pruning, which often results in ungrammatical "word salad," R2C's sentence-level approach preserves semantic integrity. This was particularly evident in Code Completion tasks, where maintaining structural logic is critical.
Conclusion and Future Work
R2C proves that a model's ability to "read" for information retrieval can be directly repurposed for effective prompt compression. By capturing global context through FiD's decoder, R2C overcomes the limitations of segment-based compressors.
Future research will focus on balancing instruction-following and context-understanding during training, as well as developing adaptive mechanisms to determine the optimal compression ratio for each unique prompt.
Summary updated