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},
}
Metadata
Release files for tiny-recursive-model 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tiny_recursive_model-0.0.15.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tiny_recursive_model-0.0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / tiny_recursive_model-0.0.15.tar.gz
| Download URL | tiny_recursive_model-0.0.15.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed3011a66be8dc365922f14c5dd2f5f31e4afc5f6191487e57c298fdd6e7cf97
|
|
BLAKE2b-256 checksum How to use checksums |
554f82c0218b4fdd6911af55e6342de46d77bf951090319b98f765d5276eb445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / tiny_recursive_model-0.0.15-py3-none-any.whl
| Download URL | tiny_recursive_model-0.0.15-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3099441e29f6f048b1b21c4bebf58ba4bc641039016ac686a0044bc22f4cc587
|
|
BLAKE2b-256 checksum How to use checksums |
4d7bfc7f929a6482ad2fa541381738aae4d8bf9897e97e412433d3566b3dd8ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|