Learning to Filter Context for Retrieval-Augmented Generation
Retrieval-Augmented Generation (RAG) has become the standard for making Large Language Models (LLMs) more factual by providing them with relevant external documents. However, retrieval systems are imperfect and often return passages that contain "distractor" information or are only tangentially related to the query. Even when a passage is technically correct, it may contain 90% fluff and only 10% actual evidence. LLMs often struggle with this "noise," leading to hallucinations or an inability to find the "needle in the haystack."
This paper introduces FILCO (Filter Context), a method designed to address these challenges through fine-grained, sentence-level context filtering. By pruning retrieved passages down to their most essential components, FILCO improves generation accuracy while significantly reducing computational costs.
Methods
The FILCO approach utilizes a two-stage pipeline to refine retrieved context:
- Identifying "Oracle" Contexts: During the training phase, when gold-standard answers are known, the authors use three measures to identify useful sentences:
- STRINC (String Inclusion): Does the sentence contain the exact answer string? (Effective for simple Q&A).
- LEXICAL Overlap: How much word-for-word overlap exists between the sentence and the answer? (Effective for dialog).
- CXMI (Conditional Cross-Mutual Information): An information-theoretic approach that measures how much more likely the model is to generate the correct answer given a specific sentence. This is particularly effective for complex reasoning tasks.
- Training the Filter ($M_{ctx}$): A filtering model (such as FLAN-T5) is trained to look at a query and a retrieved passage to predict which sentences satisfy the oracle measures above, allowing the system to function without gold-standard answers at test time.
- Generation ($M_{gen}$): The final generator receives only the filtered, high-quality sentences, simplifying the generation task.
Key Insights and Results
The researchers evaluated FILCO on six knowledge-intensive benchmarks, including NaturalQuestions, TriviaQA, HotpotQA, ELI5, FEVER, and Wizard of Wikipedia. Key findings include:
- Accuracy Boost: FILCO consistently outperformed both full-context and passage-wise filtering. On NaturalQuestions, it improved Exact Match (EM) scores by up to +8.6 with Llama 2. On the FEVER fact verification dataset, it saw a +6.2 accuracy jump.
- Efficiency Gains: By removing 44-64% of tokens from the prompt, FILCO significantly reduces the computational cost (KV cache size and processing time) for the generation model.
- Sentence-level Precision: Filtering at the sentence level provides a "Goldilocks" zone—offering enough context for evidence without the distracting noise of full passages or the fragmentation of token-level filtering.
- Robustness to Retrieval Failure: FILCO improves performance even when retrieved passages are "negative" (don't contain the answer) by filtering out misleading content that might otherwise trick the model.
Limitations and Future Work
While FILCO demonstrates significant improvements, the authors note that performance may vary in specialized domains like legal or medical text. Additionally, while the method saves time during generation, it introduces an extra inference step for the filtering model. Future work will explore making the filtering model faster and developing automated methods for selecting the best filtering "recipe" (STRINC, LEXICAL, or CXMI) for a given query.
Summary updated