TL;DR
Instruction-Aware Contextual Compression (IACC) optimizes Retrieval-Augmented Generation (RAG) by filtering irrelevant "noise" from retrieved documents. By utilizing both ranking and generative signals, this method achieves a 2.2x inference speedup and a 50% reduction in context costs with minimal impact on model performance.
Introduction: The RAG Clutter Problem
Retrieval-Augmented Generation (RAG) is a cornerstone for reducing hallucinations in Large Language Models (LLMs) by providing external, grounded knowledge. However, standard RAG often suffers from a "clutter" problem: retrievers frequently return lengthy documents where only small segments are relevant to the user's specific query.
Processing this "coarse-grained" context directly leads to three major inefficiencies:
- Performance Degradation: Irrelevant information can distract the LLM, leading to lower-quality responses.
- Increased Latency: Long sequences increase the time required for the model to generate the first token.
- Higher Costs: API-based models charge per token, making redundant context expensive.
While context compression exists, many methods are instruction-agnostic. This paper argues that effective compression must be instruction-aware, as the relevance of a document segment depends entirely on the specific question being asked.
Methods: Instruction-Aware Contextual Compression (IACC)
The authors propose the Instruction-Aware Contextual Compressor (IACC), a specialized module designed to sit between the retriever and the LLM to refine the context before it reaches the final generator.
The IACC is built on an encoder-decoder architecture, specifically initialized with umT5 weights. It processes the input instruction and retrieved documents to identify the most pertinent information through a dual-head mechanism.
Training and Compression Strategies
The system employs a two-stage training process:
- Ranking-Based Learning: The model learns to score document chunks based on their alignment with the instruction.
- Generative Learning: The model is trained to generate a response based on the provided context.
To compress text during inference, IACC uses three strategies:
- Compression by Ranking: The document is split into chunks, and the ranking head scores them. Only the top-scoring chunks are retained.
- Compression by Generation: Using Grad-CAM (Gradient-weighted Class Activation Mapping), the system analyzes cross-attention layers. By calculating the gradients of generated tokens relative to the input context, it identifies the specific sentences the model relied on most.
- Ensemble Approach: The most robust results are achieved by averaging the ranks from both the ranking and generation methods.
Evaluation and Datasets
The IACC was evaluated using a mix of large-scale Chinese and English datasets, including T2Ranking (307K queries), M3E (22M sentence pairs), and Dureader. Additionally, the authors introduced WikiQA-LongForm, a new benchmark based on Wikipedia entries designed specifically for long-form open-domain QA and context compression evaluation.
Key Insights and Results
The study yielded several critical findings:
- Generative Signals are Superior: Surprisingly, compression based on generative signals outperformed ranking signals, despite the generative training using only 10% of the data. This suggests that the "effort" a model exerts to generate an answer is a high-quality indicator of relevance.
- Instruction-Awareness is Essential: IACC significantly outperformed instruction-agnostic methods like "Selective Context," proving that relevance cannot be determined in a vacuum.
- Efficiency Gains: At a 0.5 retention ratio (discarding 50% of the context), the system achieved a 2.2x increase in inference speed and a 50% reduction in context-related costs.
- Accuracy Preservation: The Rouge-1 score drop was negligible (0.047). In some instances, removing noise actually improved Rouge-2 and Rouge-L scores, as the LLM could focus better on relevant data.
Limitations and Future Work
While effective, the model's performance drops sharply when retention falls below 20%. Additionally, the current implementation is tied to an encoder-decoder setup (umT5); future research is needed to determine if similar Grad-CAM signals can be extracted efficiently from large decoder-only models like Llama 3 without significant overhead.
Summary updated