[2605.26099] Language Models Need Sleep
Abstract:Transformer-based large language models are increasingly used for long-horizon tasks; however, their attention mechanism scales poorly with context length. To handle this, we study a sleep-like consolidation mechanism in which a model periodically converts recent context into persistent fast weights before clearing its key-value cache. During sleep, the model performs $N$ offline recurrent passes over the accumulated context and updates the fast weights in its state-space model (SSM) blocks through a learned local rule. During inference, this shifts extra computation to sleep while preserving the latency of wake-time prediction. We test our method on controlled synthetic tasks, including cellular automata and multi-hop graph retrieval, as well as a realistic math reasoning task, on which a regular transformer as well as SSM-attention hybrid models fail. We then show that increasing sleep duration $N$ for our models improves performance, with the largest gains on examples that require deeper reasoning.
View PDF HTML (experimental) Abstract:Transformer-based large language models are increasingly used for long-horizon tasks; however, their attention mechanism scales poorly with context length. To handle this, we study a sleep-like consolidation mechanism in which a model periodically converts recent context into persistent fast weights before clearing its key-value cache. During sleep, the model performs $N$ offline recurrent passes over the accumulated context and updates the fast weights in its state-space model (SSM) blocks through a learned local rule. During inference, this shifts…
saved by
related reading
- Log-Linear Attentionarxiv.org
- transformer_attention.pdfarxiv.org
- [2512.23675] End-to-End Test-Time Training for Long Contextarxiv.org
- [2501.00663] Titans: Learning to Memorize at Test Timearxiv.org
- Fast Inference from Transformers via Speculative Decodingarxiv.org
- [2604.11791] A Mechanistic Analysis of Looped Reasoning Language Modelsarxiv.org
- H3: Language Modeling with State Space Models and (Almost) No Attention · Hazy Researchhazyresearch.stanford.edu
- Fast Inference from Transformers via Speculative Decodingarxiv.org
- A History of Large Language Modelsgregorygundersen.com
- Scalable MatMul-free Language Modelingarxiv.org
- [2506.06266] Cartridges: Lightweight and general-purpose long context representations via self-studyarxiv.org
- [2212.14052] Hungry Hungry Hippos: Towards Language Modeling with State Space Modelsarxiv.org