Skip to main content

Tiny Recursive Model

Project description

trm-fig1

Tiny Recursive Model (TRM)

Implementation of Tiny Recursive Model (TRM), improvement to HRM from Sapient AI, by Alexia Jolicoeur-Martineau

Official repository is here

Interview with Alexia!

Paper review by bycloud

trm-fig3

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiny_recursive_model-0.0.14.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiny_recursive_model-0.0.14-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file tiny_recursive_model-0.0.14.tar.gz.

File metadata

  • Download URL: tiny_recursive_model-0.0.14.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for tiny_recursive_model-0.0.14.tar.gz
Algorithm Hash digest
SHA256 919107badbc3be2e3d676ffd108f173eb25898e6cc1c0a9eb9ca52a81ad27d7b
MD5 9013e1ca2c738060ed665aa268a8de21
BLAKE2b-256 f772378495ac76d4d3a75af8e9d42862013c01bd804819b1cfc09354afe239bc

See more details on using hashes here.

File details

Details for the file tiny_recursive_model-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for tiny_recursive_model-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 224da010545070de4279fd664545c5691311bd1c78698016f3775f0a9fc8be65
MD5 577b3d3a99b3169d9f8d11306b5869b7
BLAKE2b-256 84160462d49cecba3663be885b1baaba3900358c1d6f8691f08a7c8d11699b0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page