arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.13875cs.CLcs.LG
收藏

GradMem: 通过测试时梯度下降将上下文写入记忆

GradMem: Learning to Write Context into Memory with Test-Time Gradient Descent

AXXX, Cognitive AI Systems Lab, Moscow, Russia(AXXX认知人工智能系统实验室,莫斯科,俄罗斯);London Institute for Mathematical Sciences, London, UK(伦敦数学科学研究所,伦敦,英国)

Yuri Kuratov, Matvey Kairov, Aydar Bulatov, Ivan Rodkin, Mikhail Burtsev

AI总结:

提出GradMem方法,利用测试时梯度下降将上下文写入紧凑记忆状态,通过自监督重构损失优化记忆令牌,在键值检索和自然语言任务上优于前向式记忆写入方法。

摘要:

许多大型语言模型应用需要基于长上下文进行条件生成。Transformer通常通过存储每层过去激活的KV缓存来支持这一点,这会产生大量内存开销。一种理想的替代方案是压缩记忆:一次性读取上下文,将其存储在紧凑状态中,并从该状态回答许多查询。我们在上下文移除设置中研究这一点,其中模型在推理时无法访问原始上下文的情况下必须生成答案。我们引入了GradMem,它通过每个样本的测试时优化将上下文写入记忆。给定一个上下文,GradMem在保持模型权重冻结的情况下,对一小部分前缀记忆令牌执行几步梯度下降。GradMem显式优化模型级的自监督上下文重构损失,从而产生带有迭代纠错的损失驱动写入操作,这与仅前向方法不同。在关联键值检索中,GradMem在相同记忆大小下优于仅前向记忆写入器,并且额外的梯度步长比重复的前向写入更有效地扩展容量。我们进一步表明,GradMem可以迁移到合成基准之外:使用预训练语言模型,它在自然语言任务(包括bAbI和SQuAD变体)上取得了有竞争力的结果,仅依赖于记忆中的编码信息。

英文摘要:

Many large language model applications require conditioning on long contexts. Transformers typically support this by storing a large per-layer KV-cache of past activations, which incurs substantial memory overhead. A desirable alternative is compressive memory: read a context once, store it in a compact state, and answer many queries from that state. We study this in a context removal setting, where the model must generate an answer without access to the original context at inference time. We introduce GradMem, which writes context into memory via per-sample test-time optimization. Given a context, GradMem performs a few steps of gradient descent on a small set of prefix memory tokens while keeping model weights frozen. GradMem explicitly optimizes a model-level self-supervised context reconstruction loss, resulting in a loss-driven write operation with iterative error correction, unlike forward-only methods. On associative key--value retrieval, GradMem outperforms forward-only memory writers with the same memory size, and additional gradient steps scale capacity much more effectively than repeated forward writes. We further show that GradMem transfers beyond synthetic benchmarks: with pretrained language models, it attains competitive results on natural language tasks including bAbI and SQuAD variants, relying only on information encoded in memory.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑