Tiny Recursive Model
Project description
Tiny Recursive Model (TRM)
Implementation of Tiny Recursive Model (TRM), improvement to HRM from Sapient AI, by Alexia Jolicoeur-Martineau
Official repository is here
Install
$ pip install tiny-recursive-model
Usage
import torch
from tiny_recursive_model import TinyRecursiveModel, MLPMixer1D, Trainer
trm = TinyRecursiveModel(
dim = 16,
num_tokens = 256,
network = MLPMixer1D(
dim = 16,
depth = 2,
seq_len = 256
),
)
# mock dataset
from torch.utils.data import Dataset
class MockDataset(Dataset):
def __len__(self):
return 16
def __getitem__(self, idx):
inp = torch.randint(0, 256, (256,))
out = torch.randint(0, 256, (256,))
return inp, out
mock_dataset = MockDataset()
# trainer
trainer = Trainer(
trm,
mock_dataset,
epochs = 1,
batch_size = 16,
cpu = True
)
trainer()
# inference
pred_answer, exit_indices = trm.predict(
torch.randint(0, 256, (1, 256)),
max_deep_refinement_steps = 12,
halt_prob_thres = 0.1
)
# save to collection of specialized networks for tool call
torch.save(trm.state_dict(), 'saved-trm.pt')
Citations
@misc{jolicoeurmartineau2025morerecursivereasoningtiny,
title = {Less is More: Recursive Reasoning with Tiny Networks},
author = {Alexia Jolicoeur-Martineau},
year = {2025},
eprint = {2510.04871},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2510.04871},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiny_recursive_model-0.0.15.tar.gz.
File metadata
- Download URL: tiny_recursive_model-0.0.15.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed3011a66be8dc365922f14c5dd2f5f31e4afc5f6191487e57c298fdd6e7cf97
|
|
| MD5 |
5d4373ac1cd322050e52476a3920a5a2
|
|
| BLAKE2b-256 |
554f82c0218b4fdd6911af55e6342de46d77bf951090319b98f765d5276eb445
|
File details
Details for the file tiny_recursive_model-0.0.15-py3-none-any.whl.
File metadata
- Download URL: tiny_recursive_model-0.0.15-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3099441e29f6f048b1b21c4bebf58ba4bc641039016ac686a0044bc22f4cc587
|
|
| MD5 |
456c82efaf01c3fae430ebc57ef1f5f1
|
|
| BLAKE2b-256 |
4d7bfc7f929a6482ad2fa541381738aae4d8bf9897e97e412433d3566b3dd8ee
|