这篇论文把上下文压缩和通信复杂度打通了,还测了Anthropic的端点,适合搞Agent的人看看。
一篇arXiv论文首次对LLM上下文压缩进行形式化分析。作者提出两个博弈框架:Context Selection Game和Context Generation Game,分别对应子集保留和摘要生成两种压缩策略。论文证明Context Generation Game与单向通信复杂度等价,压缩预算等于同一误差下的单向通信复杂度。还证明存在一组查询,生成式压缩比选择式压缩需要更少预算。案例研究评估了Anthropic上下文压缩端点在一组集合成员查询上的表现。
Context Compaction Theory
Large Language Models (LLMs) have a bounded context window. The context window is the maximum input size an LLM can consume for a single inference. AI agents rely on a process called context compaction to fit their state within the context window when calling an LLM. Despite its ubiquity, context compaction has received essentially no formal analysis. In this paper, we initiate a formal study of context compaction. We first introduce a framework consisting of two games that capture the two algorithmic strategies for context compaction used by contemporary AI agents in practice. The Context Selection Game models context compaction algorithms that select a subset of an agent's accumulated state to retain. The Context Generation Game models context compaction algorithms that summarize an agent's state by an arbitrary message of bounded length. We then prove an equivalence between the Context Generation Game and one-way communication complexity. The minimum context compaction budget for answering a set of queries within a target error is equal to the one-way communication complexity of the induced communication problem at the same error. Known bounds from communication complexity therefore transfer directly to context compaction. We also show that the Context Selection Game corresponds to a restricted class of one-way communication protocols. Any gap between selection and generation is therefore a gap between two classes of communication protocols. We prove that there exists a set of queries for which generation needs strictly less budget than selection. The equivalence between the Context Generation Game and one-way communication also lets us measure how well a deployed context compaction algorithm performs on a query relative to the optimal strategy. As an example, we present a case study that evaluates Anthropic's context compaction endpoint on set membership queries.