AttentionRAG: Attention-Guided Context Pruning in Retrieval-Augmented Generation

Yixiong Fang, Tianran Sun, Yuling Shi, Xiaodong Gu
3/13/2025
cs.CLcs.AI

No confident code implementation found for this paper.

Abstract

While RAG demonstrates remarkable capabilities in LLM applications, its effectiveness is hindered by the ever-increasing length of retrieved contexts, which introduces information redundancy and substantial computational overhead. Existing context pruning methods, such as LLMLingua, lack contextual awareness and offer limited flexibility in controlling compression rates, often resulting in either insufficient pruning or excessive information loss. In this paper, we propose AttentionRAG, an attention-guided context pruning method for RAG systems. The core idea of AttentionRAG lies in its attention focus mechanism, which reformulates RAG queries into a next-token prediction paradigm. This mechanism isolates the query's semantic focus to a single token, enabling precise and efficient attention calculation between queries and retrieved contexts. Extensive experiments on LongBench and Babilong benchmarks show that AttentionRAG achieves up to 6.3$\times$ context compression while outperforming LLMLingua methods by around 10\% in key metrics.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{fang2025attentionrag,
  title  = {AttentionRAG: Attention-Guided Context Pruning in Retrieval-Augmented Generation},
  author = {Yixiong Fang and Tianran Sun and Yuling Shi and Xiaodong Gu},
  year   = {2025},
  eprint = {2503.10720},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.10720v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.10720.svg)](https://codeofpaper.com/paper/2503.10720)

Discussion