Do Language Models Need Sleep? Offline Recurrence for Improved Online Inference
cs.CL, cs.AI
Submitted: 2026-05-25
Updated: 2026-11-30
Comments: NeurIPS 2026
License: http://creativecommons.org/licenses/by/4.0/
The gist: Transformer-based large language models are increasingly used for long-horizon tasks; however, their attention mechanism scales poorly with context length.
Terminology
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 the 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 the 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 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. Code available at https://github.com/sangyun884/llm-sleep
Sources
- Simple linear attention language models balance the recall-throughput tradeoff
- A General Language Assistant as a Laboratory for Alignment
- Short window attention enables long-term memorization
- InfiniteICL: Breaking the Limit of Context Window Size via Long Short-term Memory Transformation
- Generative Adapter: Contextualizing Language Models in Parameters with A Single Forward Pass
- Training Verifiers to Solve Math Word Problems
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
- Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models
- Universal Transformers
- Hymba: A Hybrid-head Architecture for Small Language Models
- Depth-Adaptive Transformer
- Cartridges: Lightweight and general-purpose long context representations via self-study
- In-context Autoencoder for Context Compression in a Large Language Model
- Adaptive Computation Time for Recurrent Neural Networks
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search
- World Models
- Dream to Control: Learning Behaviors by Latent Imagination
- Repeat After Me: Transformers are Better than State Space Models at Copying
- Sleep-time Compute: Beyond Inference Scaling at Test-time
- Transformers Learn Shortcuts to Automata
Related papers
- MedGame: Storytelling Gamification Empowered by Large Language Models for Medical Education
- SparDA: Sparse Decoupled Attention for Efficient Long-Context LLM Inference
- UniVer: A Unified Perspective for Multi-step and Multi-draft Speculative Decoding
- Grounding Text Embeddings in Stakeholder Associations
- Linguistic and Argument Diversity in Synthetic Data for Function-Calling Agents
- TRIM: Achieving Extreme Sparsity with Targeted Row-wise Iterative Metric-driven Pruning