TL;DR
This paper introduces AttnComp, a novel method for compressing retrieved documents in Retrieval-Augmented Generation (RAG) systems. AttnComp adaptively filters irrelevant context using LLM attention mechanisms, leading to improved accuracy, significant compression, and reduced latency. It also provides a confidence score for RAG responses, indicating their reliability.
What Problem Does This Paper Address?
Retrieval-Augmented Generation (RAG) aims to improve Large Language Models (LLMs) by providing them with external context. However, RAG systems often struggle with irrelevant or noisy retrieved information. This noise can mislead LLMs, increase computational costs due to long input sequences, and make it harder for the model to identify and utilize truly important information. Context compression techniques aim to solve this by filtering out irrelevant content before it reaches the LLM. Existing methods, however, often lack adaptivity to varying context relevance, suffer from high latency, or fail to effectively integrate information across multiple documents.
Methods
AttnComp is a two-stage framework:
- Attention Computation: It leverages the inherent attention mechanisms of LLMs. Given a prompt (instruction, retrieved documents, and query), it computes attention weights from the LLM's middle layers to quantify the relevance of each text segment to the query.
- Top-P Compression: This stage uses the computed attention weights to rank documents. A Top-P algorithm retains the minimal set of documents whose cumulative attention scores (combined with the instruction's score) exceed a predefined threshold. This allows for adaptive compression, adjusting the amount of retained context based on its relevance. AttnComp also fine-tunes the cross-attention layer to better direct attention to relevant documents or the instruction itself when no relevant documents are found.
Additionally, AttnComp estimates response confidence by monitoring the attention assigned to the instruction. A higher instruction attention score suggests lower retrieval quality, correlating with lower response reliability.
Datasets
- Training Data: Constructed from the HotpotQA training split, including 8,000 examples, with 2,000 specifically designed to have all documents irrelevant to the question.
- Evaluation Datasets:
- Single-hop QA: Natural Questions (NQ), PopQA.
- Multi-hop QA: HotpotQA, 2WikiMultiHopQA, MuSiQue.
- Retrieval Corpus: Wikipedia dump from December 2018.
The paper also mentions the LooGLE benchmark for analyzing attention patterns.
Key Insights and Ideas
- Middle-layer attention heads are crucial for relevance: The study found that certain attention heads in the middle layers of LLMs are particularly adept at focusing on supporting evidence sentences, suggesting their inherent ability to capture relevance.
- Attention adapts to context density: The way LLMs distribute attention changes based on whether relevant information is concentrated in a single sentence (short-dependency tasks) or spread across multiple sentences (long-dependency tasks).
- Attention on initial tokens signals irrelevance: When retrieved context becomes less relevant, LLMs tend to allocate more attention to the initial tokens of the context. This "attention sink" behavior can be a useful signal for estimating retrieval quality.
- Adaptive compression is key: Fixed compression rates are suboptimal. AttnComp's Top-P approach, guided by attention, dynamically adjusts the amount of context retained, leading to better performance.
- Confidence estimation from instruction attention: The attention paid to the instruction itself can serve as a reliable indicator of the quality of retrieved documents and, consequently, the trustworthiness of the RAG response.
Key Results
- Accuracy Improvement: AttnComp achieved a 1.9 point accuracy improvement over the uncompressed baseline, while other compression methods led to a decrease of at least 3 points. For multi-hop QA, it showed a 5.4 point improvement over sentence-level compression methods.
- Compression Rate: AttnComp achieved a 17x compression rate, outperforming other evaluated extractive methods.
- Latency Reduction: The system's end-to-end latency was reduced to 49% of the uncompressed baseline.
- Confidence Estimation: A strong positive correlation was observed between AttnComp's confidence score and the F1 score of RAG responses, indicating its utility for assessing answer reliability.
- Robustness: AttnComp maintained strong performance across varying numbers of retrieved documents and different Top-P thresholds. It also showed comparable accuracy to document-level compression when applied at the sentence level.
Limitations and Future Work
- Model Size: Experiments were conducted on LLMs up to 8 billion parameters; effectiveness on larger models is not evaluated.
- Architecture Specificity: The work focuses on dense model architectures; applicability to Mixture-of-Experts (MoE) models is unexplored.
- Annotation Pipeline: The automated annotation pipeline relies on an LLM (Llama-3.1-8B-Instruct), which may introduce some errors due to potential hallucinations.
- Confidence Estimation Scope: The confidence estimation method focuses solely on retrieved document quality, potentially overlooking other factors like the LLM's internal knowledge or integration strategies.
Future work could explore the effectiveness of AttnComp on larger models, investigate its applicability to other architectures, and develop more comprehensive confidence estimation methods. The authors also suggest exploring iterative RAG frameworks that leverage confidence estimates for further refinement.
Summary updated