HRM
Hierarchical Reasoning Model Official Release
What is HRM?
Hierarchical Reasoning Model Official Release
Overview of HRM
What it is
Hierarchical Reasoning Model (HRM) is a recurrent neural architecture for sequential reasoning tasks. It executes reasoning in a single forward pass without explicit supervision of intermediate steps. The model consists of two interdependent recurrent modules: a high-level module for slow, abstract planning and a low-level module for rapid, detailed computations. HRM has 27 million parameters and achieves strong performance on complex reasoning tasks using only 1000 training samples, without pre-training or Chain-of-Thought data.
Key features
- Two interdependent recurrent modules (high-level and low-level) for hierarchical reasoning
- Single forward pass without explicit intermediate supervision
- 27 million parameters
- Trained on only 1000 samples, no pre-training or CoT data required
- Achieves near-perfect performance on complex Sudoku puzzles and optimal path finding in large mazes
- Outperforms much larger models with longer context windows on the Abstraction and Reasoning Corpus (ARC)
Use cases
- Solving complex Sudoku puzzles (9x9 extreme)
- Optimal path finding in large mazes (30x30 hard)
- Abstraction and Reasoning Corpus (ARC) tasks
Getting started
### Prerequisites: Install CUDA 12.6 and PyTorch with CUDA 12.6
CUDA_URL=https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run
wget -q --show-progress --progress=bar:force:noscroll -O cuda_installer.run $CUDA_URL
sudo sh cuda_installer.run --silent --toolkit --override
export CUDA_HOME=/usr/local/cuda-12.6
PYTORCH_INDEX_URL=https://download.pytorch.org/whl/cu126
pip3 install torch torchvision torchaudio --index-url $PYTORCH_INDEX_URL
pip3 install packaging ninja wheel setuptools setuptools-scm
### Install FlashAttention (for Hopper GPUs)
git clone [email protected]:Dao-AILab/flash-attention.git
cd flash-attention/hopper
python setup.py install
### Install Python dependencies
pip install -r requirements.txt
### Quick Demo: Sudoku Solver
python dataset/build_sudoku_dataset.py --output-dir data/sudoku-extreme-1k-aug-1000 --subsample-size 1000 --num-aug 1000
OMP_NUM_THREADS=8 python pretrain.py data_path=data/sudoku-extreme-1k-aug-1000 epochs=20000 eval_interval=2000 global_batch_size=384 lr=7e-5 puzzle_emb_lr=7e-5 weight_decay=1.0 puzzle_emb_weight_decay=1.0
License and pricing
Licensed under Apache-2.0. Open source.
Based on the project's public README and repository metadata.