lucidrains/titans-pytorch

Unofficial implementation of Titans, SOTA memory for transformers, in Pytorch

What it solves

This project provides an unofficial implementation of the "Titans" architecture, which focuses on enabling neural networks to learn and memorize information at test time. It addresses the challenge of creating sequence models that can effectively store and retrieve context beyond standard attention mechanisms.

How it works

It implements a "Neural Memory" module that acts as a specialized component for storing information. The library also includes a "Memory as Context" (MAC) transformer, which integrates these memory components into a standard transformer structure. Users can configure memory tokens for both persistent and long-term storage, allowing the model to process sequences while maintaining a dynamic memory state.

Who it’s for

This library is intended for researchers and developers working with PyTorch who want to experiment with the Titans architecture or explore novel neural memory modules beyond simple multi-layer perceptrons.

Highlights

  • Includes a modular NeuralMemory component for PyTorch.
  • Provides a MemoryAsContextTransformer implementation for sequence modeling.
  • Supports configurable memory tokens and attention windows.
  • Includes experimental training scripts to test architecture performance.

Related

  • Project
  • Project
  • Project
  • Project