为长文本任务设计记忆地图,让AI更高效理解重复上下文。
PEEK: Context Map as an Orientation Cache for Long-Context LLM Agents

- 用可编程缓存维护上下文地图,持续记录内容结构与关键信息。
- 在长文本推理中提升6.3%-34.0%,迭代次数减少93-145次。
- 适合处理文档库、代码库等重复性长上下文任务的AI代理使用。
大型语言模型(LLM)代理越来越多地在长且重复的外部上下文中运行,如文档集合和代码仓库。现有方法仅保存代理轨迹、原始材料访问或任务策略,却未保留我们所认为最关键的:关于重复上下文本身的可复用定位知识(例如内容构成、组织方式及历史上有用的实体、常量与模式)。本文提出PEEK系统,将此类定位知识以“上下文地图”形式缓存——一种小型、固定大小的提示组件,使代理能持续“窥探”外部上下文。该地图由三个模块维护:提取推理信号中可迁移知识的Distiller,将其转化为结构化编辑的Cartographer,以及基于优先级淘汰的Evictor,确保固定令牌预算。在长上下文推理与信息聚合任务上,PEEK相较强基线提升6.3%-34.0%,迭代次数减少93-145次,成本降低1.7-5.8倍;在上下文学习任务中,求解率与评分准确率分别提升6.0%-14.0%和7.8%-12.1%,成本仅为ACE的1.4倍。这些优势在多种模型与代理架构(包括OpenAI Codex)上均成立,表明上下文地图显著提升了代理对重复长上下文的交互准确性与效率。
原文摘要 · Abstract (English)
Large language model (LLM) agents increasingly operate over long and recurring external contexts, like document corpora and code repositories. Across invocations, existing approaches preserve either the agent's trajectory, passive access to raw material, or task-level strategies. None of them preserves what we argue is most needed for repeated same-context workloads: reusable orientation knowledge (e.g., what the context contains, how it is organized, and which entities, constants, and schemas have historically been useful) about the recurring context itself. We introduce PEEK, a system that caches and maintains this orientation knowledge as a context map: a small, constant-sized artifact in the agent's prompt that gives it a persistent peek into the external context. The map is maintained by a programmable cache policy with three modules: a Distiller that extracts transferable knowledge from inference-time signals, a Cartographer that translates it into structured edits, and a priority-based Evictor that enforces a fixed token budget. On long-context reasoning and information aggregation, PEEK improves over strong baselines by 6.3-34.0% while using 93-145 fewer iterations and incurring 1.7-5.8x lower cost than the state-of-the-art prompt-learning framework, ACE. On context learning, PEEK improves solving rate and rubric accuracy by 6.0-14.0% and 7.8-12.1%, respectively, at 1.4x lower cost than ACE. These gains generalize across LMs and agent architectures, including OpenAI Codex, a production-grade coding agent. Together, these results show that a context map helps long-context LLM agents interact with recurring external contexts more accurately and efficiently.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。