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

URM

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.15.tar.gz (10.0 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.15-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

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

Hashes for tiny_recursive_model-0.0.15.tar.gz
Algorithm Hash digest
SHA256 ed3011a66be8dc365922f14c5dd2f5f31e4afc5f6191487e57c298fdd6e7cf97
MD5 5d4373ac1cd322050e52476a3920a5a2
BLAKE2b-256 554f82c0218b4fdd6911af55e6342de46d77bf951090319b98f765d5276eb445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tiny_recursive_model-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3099441e29f6f048b1b21c4bebf58ba4bc641039016ac686a0044bc22f4cc587
MD5 456c82efaf01c3fae430ebc57ef1f5f1
BLAKE2b-256 4d7bfc7f929a6482ad2fa541381738aae4d8bf9897e97e412433d3566b3dd8ee

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