GradMem: Learning to Write Context into Memory with Test-Time Gradient Descent
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.
Code (0)
등록된 구현이 없습니다.
Similar Papers 제목 키워드 기반
Gated Differentiable Working Memory for Long-Context Language Modeling
Long contexts challenge transformers: attention scores dilute across thousands of tokens, critical information is often lost in the middle, and models struggle to adapt to novel patterns at inference time. Recent work on…
Test-time AdaptationWhenLoss: Diagnosing Write and Retrieval Bottlenecks in Long-Context Memory Systems
Long-context memory systems often fail under fixed budgets, but end-to-end evaluation does not reveal whether evidence was discarded during compression or preserved but never retrieved. We introduce a four-condition diag…
Titans-as-a-Layer: Test-Time Memory for Conversational Speech Emotion Recognition
Speech emotion recognition (SER) is commonly formulated as utterance-level classification, although conversational emotion depends on a speaker's usual vocal range and the emotional context established by previous uttera…
Speech Emotion RecognitionErase-then-Delta Attention: Decoupling Erase and Write Addresses in Delta-Rule Linear Attention
Delta-rule linear attention improves recurrent memory updates by correcting what is already stored at the current write address before writing new content. However, the active correction is still anchored to that same wr…
Ubicomp Digital 2020 -- Handwriting classification using a convolutional recurrent network
The Ubicomp Digital 2020 -- Time Series Classification Challenge from STABILO is a challenge about multi-variate time series classification. The data collected from 100 volunteer writers, and contains 15 features measure…
ClassificationGeneral ClassificationTime SeriesTime Series Analysis+1