arXiv(opens in a new tab)cs.CLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.30811

TopoCompress: Long Context Compression via Graph-Wired Semantic Trajectories

Daniel Agyei Asante, Yang Li

Abstract

Long-context compression is essential for reducing the cost and latency of large language model inference. However, existing methods can fragment important evidence, require additional training or alignment, and often depend on the target model for effective compression. We introduce TopoCompress, a training-free and model-agnostic framework that compresses long contexts by selecting coherent semantic spans. TopoCompress first scores each span using dense and lexical query relevance together with semantic acceleration. It then constructs a hybrid graph that connects spans based on semantic similarity and sequential adjacency, and propagates the query-guided relevance scores over the graph. Across five long-context tasks—HotpotQA, 2WikiMQA, MuSiQue, Qasper, and MultiFieldQA—TopoCompress consistently outperforms strong compression baselines. Notably, TopoCompress achieves performance comparable to the strongest baseline while using a 4×4\times smaller compression budget, and provides a 1.41×1.41\times smaller compression time over the fastest baseline.

1 Introduction

Large language models (LLMs) have demonstrated strong capabilities when supplied with sufficiently rich context (Lewis et al., 2020). Many complex natural language tasks require models to reason over heterogeneous sources of information, such as instructions, demonstrations, retrieved documents, conversation history, and task-specific evidence. However, existing LLMs remain constrained by finite context windows. Although substantial effort has been devoted to extending these windows, longer contexts introduce two major challenges. First, they increase inference cost and latency because the target LLM must process a larger number of input tokens (Dao et al., 2022; Keles et al., 2023). Second, simply providing a model with more context does not necessarily improve its performance. As the input grows longer, models may struggle to effectively use relevant evidence, especially when it appears in the middle of the context (Liu and Lapata, 2019).

Long-context compression has therefore emerged as an important approach for reducing inference cost and helping models focus on the most relevant information in long inputs. Most existing context compression methods (Li et al., 2023; Jiang et al., 2023, 2024) formulate compression as a token-level pruning problem. Thus, given a long context and a compression budget, their goal is to remove tokens estimated to be less important while retaining those required to answer the question. A representative example is LLMLingua (Jiang et al., 2023), which introduces a coarse-to-fine compression framework that uses a smaller auxiliary language model MSM_{S} to estimate the perplexity of tokens in a long context. Tokens with lower perplexity are treated as contributing less information and are removed through an iterative procedure. This approach does not consider the relevance of tokens to the question before dropping them. LongLLMLingua (Jiang et al., 2024) extends this formulation by making context compression question-aware. In particular, LongLLMLingua uses contrastive perplexity to measure how token importance changes when the context is conditioned on the question, thereby encouraging the compressor MSM_{S} to retain question-relevant information.

While these methods demonstrate the usefulness of context compression, their token-level perplexity-based formulation introduces several operational limitations. First, token-level pruning can fragment the context (Figure 1). Since compression decisions are made over individual tokens, the resulting compressed context may break word boundaries, phrases, named entities, or syntactic units.

∗^{*}Corresponding author. Email: jerryyangli@gmail.com.

This can distort the information seen by the target model and may require post-hoc recovery (Jiang et al., 2024), which adds extra computation. A more principled compression method should avoid creating such fragmentation in the first place.

Second, these methods are not model-agnostic. The compressor MSM_{S} decides which information should be removed, and the target model MTM_{T} then uses the resulting compressed context during inference to answer the query. MSM_{S} must learn to imitate what MTM_{T} would consider informative in order to make reliable compression decisions. Existing context compression methods (Jiang et al., 2023, 2024) attempt to reduce this mismatch through instruction-tuning, where MSM_{S} is adapted using responses generated by MTM_{T}. However, this alignment introduces additional computation and ties the compressor to a specific target model, limiting its generality across different LLMs.

Third, perplexity-based importance scores do not account for how pieces of evidence relate to one another. Existing compression methods (Li et al., 2023; Jiang et al., 2023, 2024) use perplexity to estimate how predictable each token is under a small language model MSM_{S}. Yet even when made question-aware, this formulation scores tokens individually rather than modeling how one piece of evidence supports or connects to another. Many multi-document and multi-hop tasks require the model to connect evidence across documents and follow causal or temporal relations before the query can be answered (Figure 4). A token may therefore be easy to predict from its local context, and thus receive low perplexity and be dropped, while still carrying intermediate information needed to preserve the evidence chain. This makes perplexity an insufficient signal for determining which information is truly important for a downstream task.

These limitations suggest that long-context compression should move beyond treating tokens as independent units whose importance can be determined solely by a compressor model MSM_{S}. Instead, compression should preserve coherent evidence, identify information that is relevant to the task, and account for relationships among different pieces of evidence. This naturally calls for a graph-based formulation, where the context is represented as a set of connected semantic units. Such a representation allows compression decisions to consider not only how relevant a piece of evidence is to the query, but also how it supports, connects, or provides intermediate information that links other evidence. Graph-based representations have been successfully used to capture relationships among textual units in applications such as summarization (Bugueño et al., 2025; Leite et al., 2007), conversational analysis (Montero and Araki, 2007), and information retrieval (Witschel, 2007). For the first time, we formulate long-context compression as graph-based relevance propagation.

Based on this formulation, we introduce TopoCompress, a training-free and model-agnostic framework for context compression. TopoCompress first segments the context into coherent semantic spans and scores them based on query relevance. It further incorporates semantic acceleration to highlight query-relevant spans that occur at informative transitions in the context. The spans are then connected through a hybrid graph based on semantic similarity and sequential adjacency. Rather than selecting evidence solely from its direct relevance to the query, TopoCompress propagates relevance over this graph, allowing intermediate, supporting spans to gain importance through their connections to other evidence. This is useful for complex reasoning tasks, where some necessary information may not directly match the query but is essential for completing the evidence chain (Appendix A).

We evaluate TopoCompress on five long-context question answering tasks—HotpotQA, 2WikiMQA, MuSiQue, Qasper, and MultiFieldQA—across several target models. The results show that TopoCompress achieves a strong balance between answer quality and compression efficiency, consistently outperforming all evaluated compression baselines across different compression budgets and target models. It also keeps the compression process lightweight and fast.

Our contributions are summarized as follows:

• We formulate long-context compression as relevance propagation over a hybrid graph. To the best of our knowledge, this graph-relevance formulation is the first of its kind for long-context compression.

• We introduce TopoCompress, a training-free and model-agnostic compression framework that selects compact, coherent, and non-redundant evidence by propagating query relevance over a hybrid graph, allowing evidence that may not directly match the query to be identified through its connections.

Figure

Figure 1: Example of entity fragmentation under token-level prompt compression. LLMLingua removes and corrupts the answer-bearing phrase, while LongLLMLingua preserves only a fragmented form. TopoCompress preserves the complete evidence.

• We show on several long-context tasks that TopoCompress provides competitive compression quality while being substantially faster.

References (6)

  • Qwen3 Technical Report
  • For example, a non-supporting span is ranked 3rd by query relevance, while graph propagation move it to rank 11
  • The controller generates intermediate reasoning queries during compression to guide additional evidence selection when the current compressed context appears insufficient
  • President: Francisco Guterres
  • $K$ denotes the compressed context budget
  • >Llama3.1-8B</td><td rowspan=