LSTMem: Hierarchical Long Short-Term Online Memory for Large Language Models
cs.AI
Submitted: 2026-09-27
Updated: 2026-09-27
License: http://creativecommons.org/licenses/by/4.0/
The gist: Large language models increasingly serve as long-horizon assistants and agents, where they must both accumulate information across interactions and make the relevant parts available when later
Terminology
Abstract
Large language models increasingly serve as long-horizon assistants and agents, where they must both accumulate information across interactions and make the relevant parts available when later requests depend on them. Existing compact online memories typically use a single persistent state both to accumulate history and to serve readout, so what the memory stores cannot be controlled separately from what it exposes to the current computation. We propose LSTMem, an LSTM-inspired online memory that instead equips each layer of a frozen LLM with two matrix-valued states: a cell state that accumulates history and a hidden state whose readouts correct the backbone's attention. Input and forget gates control what the cell stores, while an output gate separately controls what the cell exposes through the hidden state. LSTMem further connects memory across depth through forward hidden-state propagation and block-end feedback, and uses higher-layer reconstruction gradients to refine lower-layer cell states before rebuilding hidden states from shallow to deep layers. Across memory benchmarks on Qwen3-4B-Instruct, LSTMem consistently improves MemoryAgentBench, LoCoMo, and HotpotQA over the plain backbone. Comparisons further show that the LSTM-based memory formulation outperforms an associative-memory counterpart, while removing cross-layer hidden-memory propagation degrades performance. These results demonstrate the benefits of separating memory accumulation from memory expression and organizing memory hierarchically across model depth. The code is available at https://github.com/Longchentong/LSTMem.
Sources
- Understanding LoRA as Knowledge Memory: An Empirical Analysis
- ATLAS: Learning to Optimally Memorize the Context at Test Time
- LoRA Learns Less and Forgets Less
- Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
- Rethinking Memory in LLM based Agents: Representations, Operations, and Emerging Topics
- Context Length Alone Hurts LLM Performance Despite Perfect Retrieval
- In-context Autoencoder for Context Compression in a Large Language Model
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces
- RULER: What's the Real Context Size of Your Long-Context Language Models?
- LoRA: Low-Rank Adaptation of Large Language Models
- TransMem: Transforming Hidden States into Memory for Large Language Models
- delta-mem: Efficient Online Memory for Large Language Models
- Decoupled Weight Decay Regularization
- Leave No Context Behind: Efficient Infinite Context Transformers with Infini-attention
- MemGPT: Towards LLMs as Operating Systems
- Eagle and Finch: RWKV with Matrix-Valued States and Dynamic Recurrence
- HGRN2: Gated Linear RNNs with State Expansion
- GPQA: A Graduate-Level Google-Proof Q&A Benchmark
- Learning to (Learn at Test Time): RNNs with Expressive Hidden States
Related papers
- MAVEN-T: Reinforced Heterogeneous Distillation for Real-Time Multi-Agent Trajectory Prediction
- Model Discovery Agent: LLM-assisted Bayesian experiment design for data-efficient discovery of mechanistic world models
- Agents' Last Exam
- The Clinician's Veto: Navigating Trust, Liability, and Uncertainty in Autonomous AI Prescribing
- MindHelper: Closed-Loop Embodied Mental-State Reasoning for Precision Intervention
- Incumbent Advantage: Brand Bias and Cognitive Manipulation Dynamics in LLM Recommendation Systems