English

Recurrent Memory-Augmented Transformers with Chunked Attention for Long-Context Language Modeling

Machine Learning 2025-07-02 v1

Abstract

We present a Transformer architecture for long-context language modeling that combines global attention with two biologically inspired components: chunked local attention and a gated FIFO memory mechanism. This unified attention block allows the model to efficiently handle both short-range and long-range dependencies without increasing attention cost quadratically. The memory module persistently stores past token representations using a gated update mechanism inspired by recurrent networks. Rotary positional encoding is applied per attention head to enable directionally disentangled, scale-invariant positional signals. The architecture is implemented entirely from scratch in PyTorch, with no reliance on high-level libraries, enabling transparent and modular experimentation. Our model offers a lightweight and extensible design for tasks such as dialogue modeling, code completion, and document understanding.

Keywords

Cite

@article{arxiv.2507.00453,
  title  = {Recurrent Memory-Augmented Transformers with Chunked Attention for Long-Context Language Modeling},
  author = {Ankit Kashyap},
  journal= {arXiv preprint arXiv:2507.00453},
  year   = {2025}
}

Comments

19 pages, 9 figures, 1 table; implemented entirely from scratch in PyTorch

R2 v1 2026-07-01T03:40:56.416Z