TensorX
返回文献探索

Paper · arXiv 2603.13875

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

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

36 upvotesMarch 14, 2026arXiv 预印本
AI 摘要

GradMem enables efficient context storage and retrieval in language models through gradient-based memory writing that outperforms traditional forward-only approaches.

TransformersKV-cachecompressive memorytest-time optimizationcontext reconstruction lossgradient descentmemory tokensforward-only methodsassociative key-value retrievallanguage models

Abstract

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 ompressive 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.

北京市昌平区探索星信息技术及软件开发工作室

京ICP备2026059466号
GradMem: Learning to Write Context into Memory with Test-Time Gradient Descent | TensorX