让大模型在查询时才构建记忆,既省资源又更准确。
LazyMem: Retrieve Broadly, Construct Selectively for Efficient Long-Term Agent Memory
- 记忆构建推迟到查询时刻,只保留与当前问题相关的内容
- 在LongMemEval上准确率达0.85,用的内存仅是基线的1/21
- 适合需要高效长时记忆的对话代理系统
长期记忆使大模型代理能够利用过往交互,但对话历史很快超出上下文窗口,迫使代理在查询时检索相关片段。由于有效信息稀疏且分散在冗长对话中,检索面临根本矛盾:扩大召回虽提升覆盖范围,却带来噪声泛滥;而写入时压缩则会不可逆地丢弃未来可能需要的细节。我们提出LazyMem,通过将所有记忆构建推迟至查询时刻来解决这一矛盾。给定候选记忆池后,轻量级模型以重叠并行窗口处理,仅选择性保留和压缩与查询相关的内容。该模型经监督微调与强化学习训练,奖励函数同时鼓励识别相关消息、生成忠实且有助于回答的压缩内容。在LongMemEval上,LazyMem-4B取得0.85的LLM判断准确率,优于最强非预言基线,仅使用213个答案-上下文记忆令牌,为基线的21.0倍减少。它还无需目标领域训练即可泛化至LoCoMo,并降低平均延迟。代码已公开于https://github.com/allacnobug/LazyMem。
原文摘要 · Abstract (English)
Long-term memory enables LLM agents to leverage past interactions, but dialogue histories quickly exceed the context window, forcing agents to retrieve relevant subsets at query time. Because useful evidence is sparse and scattered across verbose conversations, retrieval faces a fundamental tension: broadening recall improves coverage but floods downstream reasoning with noise, while compressing memories at write time eases retrieval but irreversibly discards details that future queries may need. We introduce LazyMem, which resolves this tension by deferring all memory construction to query time. Given a retrieved candidate pool, a lightweight model processes it in overlapping parallel windows, selectively retaining and compressing only query-relevant content. The model is trained with supervised fine-tuning followed by reinforcement learning, using a reward that jointly encourages the identification of relevant messages and the generation of compressions that are faithful to the source and useful for answering the query. On LongMemEval, LazyMem-4B achieves an LLM-judge accuracy of 0.85, outperforming the strongest non-oracle baseline while using only 213 answer-context memory tokens, 21.0 times fewer than the baseline. It further generalizes to LoCoMo without target-domain training and reduces mean latency relative to the prior query-time baseline. Code is available at https://github.com/allacnobug/LazyMem.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。