NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Stateful Memory-Augmented Transformers for Dialogue Modeling

Qingyang Wu, Zhou Yu · DOI

Introduction

Standard Transformer models face a fundamental "memory vs. efficiency" trade-off in dialogue modeling. Because self-attention complexity scales quadratically ($O(n^2)$) with sequence length, processing long conversation histories becomes computationally prohibitive. To maintain real-time performance, many systems truncate history to a small window (e.g., 128 tokens), which causes the model to "forget" critical context from earlier turns.

This paper introduces MemBART, a stateful memory-augmented Transformer that enables encoder-decoder models to maintain long-term dialogue context without the quadratic overhead. By utilizing a novel dual-attention stream and gated memory updates, MemBART achieves significant performance gains and up to an 11x speedup in latency compared to stateless long-context baselines.

The Shift from Stateless to Stateful Modeling

Existing solutions for long-range dependencies, such as the Longformer Encoder-Decoder (LED), typically rely on sparse attention mechanisms. However, these models remain stateless: they must re-process the entire context window at every step to retrieve information.

Comparison between stateless models (a), which infer history from raw context, and stateful models (b), which pass a memory state M across time steps.

In contrast, a stateful model maintains an internal, compressed representation of the past (a memory state $M$). This allows the model to carry forward relevant information from previous turns without needing to re-read the raw text of the entire history at every interaction, drastically reducing the computational footprint for multi-turn dialogue.

The MemBART Architecture

MemBART adapts the pre-trained BART architecture into a stateful framework through two primary innovations: the Dual Attention Stream and Residual Gated Memory Updates.

Dual Attention Stream

Unlike previous memory-augmented models that inject new layers directly into the Transformer—often disrupting pre-trained knowledge—MemBART employs two parallel attention paths at each layer. One path processes the current input sequence, while the other updates memory slots. This architecture allows for fluid information exchange between the memory and the context with minimal interference to the original model's weights.

The MemBART architecture featuring the Dual Attention Stream (left) and the Memory Writer/Update mechanism (right).

Residual Gated Memory Update

To prevent information loss as signals pass through deep layers, the researchers implemented a gating mechanism similar to a Gated Recurrent Unit (GRU). This allows the model to explicitly decide which information in a memory slot should be retained, overwritten, or updated based on the new context.

Training and Evaluation

The researchers employed a two-stage training strategy to optimize the memory module:

  1. Text Recall: A bottleneck task where the model must recover the previous segment of text using only the memory state. This served as a diagnostic for architecture selection.
  2. Sequence Denoising: The memory module is trained to reconstruct masked tokens from previous segments, forcing it to prioritize high-value information like named entities and key facts.

The model was evaluated on several benchmarks, including Multi-Session Chat (MSC), which contains human-human conversations spanning multiple sessions, and PersonaChat, which requires consistent personality maintenance.

Key Results and Insights

MemBART demonstrates that stateful architectures are significantly more efficient than stateless ones for dialogue tasks. On the MSC dataset, MemBART-base achieved perplexity comparable to LED-base while being 11.15x faster. The larger variant, MemBART-large, was 6.40x faster than its LED counterpart.

Other critical findings include:

  • Context Compression: In PersonaChat, MemBART using only 64 context tokens performed on par with a standard BART model using 512 context tokens, demonstrating the power of its compressed memory.
  • Weight Sharing: The authors discovered that sharing weights between the memory module and the main Transformer actually degraded performance. Because memory states and word embeddings exist in different distribution spaces, they require distinct parameters.
  • Learning Dynamics: The model requires a specific "warm-up" period. Performance gains only materialize once the gradient norm of the memory module reaches a peak, indicating the point where the model learns to effectively store and retrieve information.

Conclusion

MemBART represents a significant step toward efficient, long-term dialogue agents. By moving from stateless context windows to a stateful memory architecture, the model overcomes the quadratic scaling limits of standard Transformers. While it currently excels in dialogue, future work will explore extending this memory-augmented approach to more structured tasks like scientific text summarization and task-oriented systems.

Summary updated

BibTeX
@inproceedings{wu2024stateful,
  author = {Qingyang Wu and Zhou Yu},
  title = {{Stateful Memory-Augmented Transformers for Dialogue Modeling}},
  booktitle = {EACL (Findings)},
  year = {2024},
}
Figure