Introduction
To make Large Language Models (LLMs) useful in real-world applications, they are often equipped with "tools"—APIs for web search, mathematical computation, or database access. For a model to utilize these tools, it must process their documentation within its input context. However, documentation is frequently verbose; a single tool description can consume hundreds of tokens. When dozens of tools are available, the documentation can overwhelm the model's context window, leaving little room for user queries and significantly increasing response latency.
Existing "soft compression" methods, which transform text into dense mathematical vectors, often suffer from information loss. In tool-use scenarios, precision is paramount; even a single-character error in a tool's name (e.g., get_weather_data vs. weather_fetcher) results in a failed call. This research introduces a method to make context compression both concise (short) and precise (error-free).
Methodology
The authors propose a dual-strategy approach to improve standard soft context compression: Selective Compression and Block Compression.
Selective Compression
The researchers observed that not all information in a document is of equal importance. Tool names and parameter keys are "key information"—any error renders them useless. Their strategy involves "cutting out" these critical identifiers and maintaining them as raw text tokens. Only the verbose, natural-language descriptions are processed by a Compressor (based on LLaMA-7b) to be converted into "soft" summary tokens.
Block Compression
Standard compression techniques often attempt to squash an entire document into a fixed number of tokens, which is inefficient for documents of varying lengths. Block compression instead divides the documentation into chunks and compresses each chunk into a small, fixed number of soft tokens. This allows the compressed output to scale naturally with the length of the original document, maintaining a consistent compression ratio (e.g., 4x, 8x, or 16x).
Experimental Setup
The approach was evaluated on two major tool-using benchmarks:
- API-Bank: A dataset of multi-turn dialogues involving 53 different tools.
- APIBench: A complex dataset simulating an automated agent using over 1,700 tools from platforms like Hugging Face.
Results and Discussion
The experimental results highlight the effectiveness of selective compression in maintaining model performance at high compression levels.
Performance at High Compression Ratios
The method achieved a 16x compression ratio while maintaining performance comparable to the "upper-bound" (the model reading full, uncompressed documentation). As shown in the performance table, the selective strategy significantly outperforms "overall" compression methods, which tend to degrade as the compression ratio increases.
Addressing the "Name Error" Bottleneck
A key insight from the study is that the primary hurdle in tool-use is syntax, not conceptual understanding. Standard compression causes "name errors" to skyrocket. By preserving names as raw text, the selective strategy bypasses this issue. Furthermore, the authors found that "soft" tokens (vectors) performed better than "hard" summarization (e.g., using GPT-4 to rewrite documentation) at high ratios, as vectors can pack more nuanced information than human-readable words.
Conclusion
This research demonstrates that selective context compression can reduce the computational overhead of tool-using LLMs by up to 16x without sacrificing functional accuracy. While the current system relies on heuristics to identify key information and requires specialized training, it provides a robust framework for efficient context management. Future work will explore automated detection of uncompressible tokens and application to other precision-sensitive domains like legal or medical documentation.
Summary updated