Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

ttt-lm-pytorch

> 编程语言
Open source

Official PyTorch implementation of Learning to (Learn at Test Time): RNNs with Expressive Hidden States

1.4K stars0 likes0 views
WebsiteGitHub

About

Official PyTorch implementation of Learning to (Learn at Test Time): RNNs with Expressive Hidden States

Learning to (Learn at Test Time): RNNs with Expressive Hidden States

Paper | JAX Codebase | Setup | Quick Start | Inference Benchmark

This is the official PyTorch model implementation of Learning to (Learn at Test Time): RNNs with Expressive Hidden States. We do not recommend training with this codebase, because it is written in pure PyTorch without any systems optimization, so training will be slow, especially when the per-device batch size is small.

For training code, or to replicate results from our paper, please view our JAX codebase. For inference kernels, or to replicate speed benchmarks from our paper, please view our kernel implementations.

Abstract

Self-attention performs well in long context but has quadratic complexity. Existing RNN layers have linear complexity, but their performance in long context is limited by the expressive power of their hidden state. We propose a new class of sequence modeling layers with linear complexity and an expressive hidden state. The key idea is to make the hidden state a machine learning model itself, and the update rule a step of self-supervised learning.

Since the hidden state is updated by training even on test sequences, our layers are called Test-Time Training (TTT) layers. We consider two instantiations: TTT-Linear and TTT-MLP, whose hidden state is a linear model and a two-layer MLP respectively.

Environment Setup

pip install "transformers[torch]"

Quick Start

Our implementation is based on Huggingface Transformers. You can use the following code to load the model and generate text.

…

Note: This is a naive implementation of TTT layers for tutorial purposes. This model can be trained using Huggingface Accelerate, or custom training loops. We have released our faster inference kernel and its speed benchmark here.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言