This repository contains PyTorch implementations of two state-of-the-art architectures designed for the ARC-AGI (Abstraction and Reasoning Corpus) benchmark:
- Tiny Recursive Model (TRM): A parameter-efficient model using nested recursive loops to refine reasoning ("Thinking") and answers ("Answering").
-
Hierarchical Reasoning Model (HRM): A dual-module architecture (Fast
$L$ -module, Slow$H$ -module) inspired by System 1 / System 2 cognitive theories.
├── data/
│ ├── arc-agi_training_challenges.json
│ └── ...
├── models/
│ ├── trm.py # Tiny Recursive Model architecture
│ └── hrm.py # Hierarchical Reasoning Model architecture
├── dataset.py # Data loading and augmentation (flip/rotate)
├── train_trm.py # Training script for TRM (Deep Supervision)
├── train_hrm.py # Training script for HRM
├── inference_new.py # Unified inference script
├── test_trm.py # Unit tests for TRM
└── test_hrm.py # Unit tests for HRM
- Concept: Uses a single shared Transformer block recursively.
-
Mechanism:
-
Inner Loop: Updates latent state
$z$ (Thinking) while keeping answer hypothesis$y$ fixed. -
Outer Loop: Updates answer hypothesis
$y$ using refined$z$ .
-
Inner Loop: Updates latent state
-
Key File:
models/trm.py
- Concept: Separate modules for perception and planning.
- Mechanism:
- L-Module (Fast): Updates frequently, solving local tactics.
- H-Module (Slow): Updates sparsely, providing global context/planning.
- Key File:
models/hrm.py
Ensure you have PyTorch installed.
pip install torch tqdm numpyPlace your ARC-AGI JSON data files in the data/ directory.
Expected standard format: arc-agi_training_challenges.json.
Train TRM:
python train_trm.pyNote: TRM uses heavy recursion. If you encounter OOM errors (especially on MPS/Mac), reduce max_seq_len in train_trm.py or batch size.
Train HRM:
python train_hrm.pyTo run inference on a sample task using a trained model:
python inference_new.pyEdit inference_new.py to point to your specific checkpoint path.
Based on the 2025 analysis of ARC-AGI architectures: "The Renaissance of Algorithmic Reasoning", implementing concepts from Samsung SAIL Montréal (TRM) and Sapient Intelligence (HRM).