test-time-training/ttt-lm-pytorch
PyTorch implementation of Test-Time Training (TTT) layers, a new class of sequence modeling layers that use self-supervised learning to update their hidden states at test time.

The repository implements TTT-Linear and TTT-MLP layers that replace traditional RNN hidden states with machine learning models themselves. The hidden state is updated through self-supervised learning steps during both training and inference, achieving linear complexity with expressive hidden states for long-context sequence modeling. The implementation is based on Huggingface Transformers for easy model loading and text generation.