用可插拔的优化算法,智能挑选大模型对话中最有用的上下文。
PACMS: Submodular Context Selection as a Pluggable Engine for LLM Agents
- 将对话、记忆和工具输出统一成候选池,按实时相关性筛选
- 在不丢失关键信息的前提下,减少30%以上上下文冗余
- 特别适合需要跨多轮记住信息的复杂任务场景
对话与工具调用型大模型代理在运行时会积累来自用户/助手对话、持久化记忆存储以及工具调用(如文件读取、搜索结果、API响应)的大量内容。当累积上下文超过模型的令牌预算时,系统需决定保留哪些内容。当前主流做法是基于时间的截断(recency truncation),常辅以周期性摘要,但这种策略无视主题相关性:早期建立的重要事实可能因过时被丢弃,而近期冗长无关内容却被保留。对于需要长期记忆的代理任务,这一机制明显失效。现有方法要么位于代理流程之外(如检索增强生成),要么仅对已有上下文进行无差别的压缩或重写,无法在提示构建时动态评估所有来源的相关性。本文提出PACMS,将记忆条目、对话回合与工具输出视为统一候选池,通过可插拔的子模函数选择机制,在提示组装阶段按实时相关性精选最相关的上下文片段。
原文摘要 · Abstract (English)
Conversational and tool-using LLM agents operate over a context window that fills from several directions simultaneously. As a session proceeds, the agent accumulates user and assistant turns, entries drawn from a persistent memory store, and often largest of all, the verbatim outputs of tool calls such as file reads, search results, and API responses. Once the cumulative context exceeds the model's token budget, the framework must decide what to keep. The prevailing mechanism is recency truncation, sometimes paired with periodic summarization. This is topic-blind: a fact established early in a session is discarded simply because it is old, even when the current user query is about exactly that fact; conversely, verbose but irrelevant recent material is retained. Agents that must recall information across many turns, the defining case for memory, are precisely where recency truncation fails. Existing alternatives sit outside the agent's assembly step. Retrieval augmented generation fetches external documents into the prompt but does not arbitrate the agent's \emph{already-present} pooled context. Context-compression methods reduce token count by rewriting or pruning text, but operate query-blind and lossily. Neither treats memory entries, conversation turns, and tool outputs as a single candidate pool to be selected from by relevance at the moment the prompt is assembled.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。