TL;DR
Large language models (LLMs) struggle with long prompts due to high computational costs and memory overhead. This paper introduces RAGP (Redundancy-Aware Graph Pruning), a novel method that models prompts as multi-layered graphs rather than flat text sequences. By using a physics-inspired "Lévy walk" algorithm, RAGP efficiently navigates these graphs to prune redundant words while preserving critical local and global context, achieving state-of-the-art prompt compression.
What Problem Does This Paper Address?
Long, information-rich prompts are essential for complex LLM tasks, but they introduce severe practical bottlenecks: high inference costs, increased latency, massive memory consumption, and performance degradation (such as the "lost-in-the-middle" phenomenon).
Existing prompt compression methods typically treat text as a flat sequence of tokens and prune them based on isolated importance metrics like raw attention scores. The authors argue that this approach ignores the structured, distributed nature of information in long documents. Important details are intricately linked through both local syntax (within a sentence) and global semantics (across sentences). By ignoring this structure, traditional methods often make suboptimal decisions—either retaining locally salient but globally redundant tokens, or discarding individually unremarkable tokens that are collectively essential to the document's meaning.
Methods
The authors propose RAGP, which transforms prompt compression into a structure-aware graph pruning problem.
- Multiplex Graph Construction: RAGP maps the input text into a two-layer ("multiplex") graph to capture multiple granularities of text structure:
- Intra-layer (Local Structure): Word-level nodes connected by edges based on token-level attention scores from a pretrained language model. This forms dense local subgraphs within individual sentences.
- Inter-layer (Global Structure): Sentence-level nodes connected by semantic similarity embeddings, creating a sparse network that maps long-range relationships across the document.
- Lévy Walk-Based Importance Estimation: Standard random walks tend to get trapped in the dense local clusters of a single sentence. To overcome this, RAGP utilizes Lévy walks—a type of random walk characterized by a heavy-tailed step-length distribution. This mathematical property allows the walker to alternate between thorough local exploration (navigating words within a sentence) and occasional long-range "jumps" (transitioning to semantically related sentences elsewhere in the document).
The importance of each word node is calculated based on its visit frequency across multiple independent walks. Nodes that act as local hubs or global semantic bridges are visited more often and prioritized for retention.
- Graph Pruning: Finally, RAGP formulates prompt compression as a budget-constrained optimization problem, selecting the highest-scoring subset of nodes that fits within the target token limit and projecting them back into their original textual order.
Datasets
RAGP was evaluated on LongBench, a comprehensive bilingual benchmark designed for long-context understanding. It includes a variety of tasks:
- Single-document QA (e.g., Qasper, NarrativeQA)
- Multi-document QA
- Summarization (e.g., QMSum, GovReport)
- Few-shot learning
- Synthetic reasoning
- Code-related tasks
The authors also utilized MultiFieldQA-En to conduct practical latency and inference cost analyses.
Key Insights and Ideas
- Text as a Multiplex Graph: Modeling text hierarchically prevents the loss of context that occurs when treating documents as flat token streams. It explicitly balances local syntactic coherence with global semantic flow.
- The Foraging Analogy: Just as animals in nature use Lévy flights to optimally forage for sparsely distributed food in heterogeneous environments, a graph traversal algorithm can use Lévy walks to efficiently forage for non-redundant, high-value information scattered across a massive document.
- Avoiding the Local Trap: Standard random walks or PageRank variants suffer from slow mixing on text graphs because they get stuck in the high-density attention loops of individual sentences. The heavy-tailed jumps of the Lévy walk naturally resolve this bottleneck.
Key Results
- State-of-the-Art Compression: On the LongBench benchmark, RAGP achieved an average score of 49.3 under a 4× compression ratio (3,000 token budget), outperforming the leading LLM-based baseline, LongLLMLingua, which scored 48.8 despite using a lower 3× compression ratio.
- Extreme Compression Resilience: Under a tighter 2,000-token constraint (6× compression), RAGP maintained a dominant average score of 48.1.
- Superiority Over Vision-Based Methods: RAGP significantly outperformed vision-based text compression models (like Glyph), particularly on precision-heavy tasks like code analysis, where RAGP led by nearly 10 points (58.8 vs 48.9).
- Real-World Cost Savings: When deployed practically on MultiFieldQA-En, RAGP reduced input tokens by 19.6%, translating directly to an 18.3% reduction in monetary API costs with negligible impact on final accuracy.
Limitations and Future Work
Despite its strong performance, the authors note a few limitations:
- Computational Overhead: Constructing the multiplex graph and running multi-round stochastic walks introduces additional preprocessing latency.
- Summarization Bottleneck: RAGP's performance on pure summarization tasks was slightly lower than some specialized baselines (22.7 vs 27.2).
- Hyperparameter Sensitivity: Key parameters, such as the graph sparsity threshold ($\delta$) and the Lévy exponent ($\mu$), currently require manual tuning depending on the document domain.
For future work, the authors plan to investigate adaptive, task-specific compression strategies and extend the multiplex graph framework to support multi-modal inputs.
Summary updated