用自一致性检查防止大模型记忆出错,让错误信息无法在对话中持续传播。
ConsistencyGate: Preventing Memory Contamination in LLM Agents via Self-Consistency Admission Control

- 在写入记忆前,通过多次提问验证事实一致性,只允许高置信度内容存入。
- 在多个真实和合成数据集上,显著降低记忆污染,尤其对隐含信息更有效。
- 无需微调、可快速部署,适合长期交互式智能体应用。
在多轮对话中,大模型代理会将信息存入外部记忆并后续复用,若某步产生幻觉事实,该错误将作为虚假前提持续影响后续推理,我们称此为记忆污染。现有记忆管理关注检索与容量,但未解决写入时的正确性问题;基于效用或新近性的策略无法避免此类污染,且污染随长轨迹累积。本文提出 ConsistencyGate,一种写入时的准入机制:在将候选事实 m 从上下文 c 中提取前,向模型查询 K 次以获取软支持分数,仅当平均分超过阈值时才允许写入。该方法与模型无关,无需微调,且可通过单次前向传播实现,适用于低延迟场景。为评估真实效果,我们构建两个基于真实对话的污染基准(LoCoMo-Contam 与 MSC-Contam),通过人为引入单细节错误生成;同时设计结构化合成数据集 MemContam,以逼近理想上限。在四个大模型骨干上,ConsistencyGate 在所有基准上均优于全写基线,尤其对源上下文中仅隐含表达的事实更有效。所有三个基准及代码均已开源。
原文摘要 · Abstract (English)
LLM agents that operate over many turns accumulate facts in an external memory store and reuse them as premises for downstream reasoning. A hallucinated fact written at one step therefore persists as a false premise for every subsequent step, a failure mode we call memory contamination. Existing memory management addresses retrieval and capacity but not write-time correctness; this admission problem cannot be solved by utility- or recency-based criteria, and uncontrolled contamination compounds across long trajectories. We propose ConsistencyGate, a write-time admission gate that, before committing a candidate fact m extracted from context c, queries the LLM K times for a soft support score and admits m only when the average exceeds a threshold. The mechanism is model-agnostic, requires no fine-tuning, and reduces to a single forward pass in a log-probability variant for latency-sensitive deployments. To measure the effect on natural data, we construct two real-conversation benchmarks (LoCoMo-Contam and MSC-Contam) by planting controlled single-detail corruptions in long-term conversations from LoCoMo and MSC, and complement them with a structured synthetic corpus (MemContam) that isolates a near-oracle upper bound. Across four LLM backbones, ConsistencyGate reduces contamination on every benchmark relative to a write-everything baseline, with the cost concentrated on facts that are stated only implicitly in the source context. We release all three benchmarks together with the gate implementation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。