As large language models engage in extended reasoning tasks, they accumulate significant state -- architectural mappings, trade-off decisions, codebase conventions -- within the context window. This understanding is lost when sessions reach context limits and undergo lossy compaction. We propose Contextual Memory Virtualisation (CMV), a system that treats accumulated LLM understanding as version-controlled state. Borrowing from operating system virtual memory, CMV models session history as a Directed Acyclic Graph (DAG) with formally defined snapshot, branch, and trim primitives that enable context reuse across independent parallel sessions. We introduce a three-pass structurally lossless trimming algorithm that preserves every user message and assistant response verbatim while reducing token counts by a mean of 20% and up to 86% for sessions with significant overhead by stripping mechanical bloat such as raw tool outputs, base64 images, and metadata. A single-user case-study evaluation across 76 real-world coding sessions demonstrates that trimming remains economically viable under prompt caching, with the strongest gains in mixed tool-use sessions, which average 39% reduction and reach break-even within 10 turns. A reference implementation is available at https://github.com/CosmoNaught/claude-code-cmv.


翻译:随着大型语言模型参与扩展推理任务,它们会在上下文窗口中积累大量状态信息——包括架构映射、权衡决策、代码库约定等。当会话达到上下文限制并经过有损压缩时,这些理解便会丢失。我们提出上下文记忆虚拟化(CMV),该系统将累积的LLM理解视为版本控制的状态。借鉴操作系统虚拟内存的思想,CMV将会话历史建模为有向无环图(DAG),并定义了形式化的快照、分支和修剪原语,使得上下文能够在独立的并行会话间复用。我们提出一种三阶段结构无损修剪算法,在完整保留每条用户消息和助手响应的同时,通过剔除机械性冗余内容(如原始工具输出、base64图像和元数据),将令牌数量平均减少20%,在存在显著开销的会话中最高可减少86%。通过对76个真实世界编码会话的单用户案例研究评估表明,在提示缓存机制下修剪仍保持经济可行性,其中混合工具使用会话的收益最为显著,平均减少39%并在10轮对话内达到盈亏平衡。参考实现可在https://github.com/CosmoNaught/claude-code-cmv获取。

0
下载
关闭预览

相关内容

大语言模型机器遗忘综述
专知会员服务
18+阅读 · 2025年11月2日
大型语言模型(LLM)赋能的知识图谱构建:综述
专知会员服务
56+阅读 · 2025年10月24日
NLP-Progress记录NLP最新数据集、论文和代码: 助你紧跟NLP前沿
中国人工智能学会
12+阅读 · 2018年11月15日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
最新内容
技术、多域威慑与海上战争(报告)
专知会员服务
1+阅读 · 今天15:04
“在云端防御”:提升北约数据韧性(报告)
专知会员服务
1+阅读 · 今天14:54
人工智能及其在海军行动中的整合(综述)
专知会员服务
0+阅读 · 今天14:07
美军MAVEN项目全面解析:算法战架构
专知会员服务
16+阅读 · 今天8:36
从俄乌战场看“马赛克战”(万字长文)
专知会员服务
10+阅读 · 今天8:19
相关基金
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员