Skip to content

Repository files navigation

title HRM Abstract Finetuning
emoji 🚀
colorFrom blue
colorTo indigo
sdk docker
pinned false
short_description HRM Abstract Finetuning for machine learning models
secrets
WANDB_API_KEY

HRM Finetuning - Anchoring Bias Model

This repository contains my finetuned version of the Hierarchical Reasoning Model (HRM) with modifications for studying anchoring bias in grant funding decisions.

What I Did Differently

1. Model Architecture Fix

  • Fixed PyTorch Compatibility Issue: Replaced deprecated nn.Buffer with register_buffer in models/hrm/hrm_act_v1.py
    # Original (deprecated):
    self.H_init = nn.Buffer(trunc_normal_init_(...))
    
    # My fix:
    h_init_tensor = trunc_normal_init_(...)
    self.register_buffer('H_init', h_init_tensor)

2. Custom Dataset & Training

  • Domain-Specific Finetuning: Trained the model on abstract optimizer data for analyzing funding decisions
  • Dataset: Created custom training.jsonl with grant abstracts and funding patterns
  • Training Infrastructure: Utilized RunPod for GPU training over 10 hours
  • Model Size: Produced a 167MB finetuned model (pytorch_model.bin)

3. Configuration Changes

  • Modified model configuration for the specific task:
    • Maintained hierarchical structure (H_cycles: 2, L_cycles: 2)
    • Optimized for abstract text processing with 512 hidden dimensions
    • Added puzzle embeddings for grant type classification (128 dimensions)

4. Deployment Architecture

  • Hugging Face Spaces Integration:
    • Created deployment-ready version at HRM-anchoring-bias-model
    • Added Dockerfile and startup scripts for containerized deployment
    • Implemented tokenizer and activity code mappings for inference

5. Project Structure Modifications

  • Removed large dataset submodules (ARC-AGI, ARC-AGI-2, ConceptARC) for cleaner deployment
  • Added comprehensive project documentation (PROJECT_TRACE.md)
  • Organized inference code separately from training code

Key Improvements Over Original

  1. PyTorch Compatibility: Works with modern PyTorch versions without deprecation warnings
  2. Specialized for Text Analysis: While original HRM focused on puzzles/games, this version analyzes grant abstracts
  3. Production Ready: Includes deployment configurations and containerization
  4. Documented Workflow: Complete trace of training and deployment process

Model Purpose

This finetuned HRM model is designed to:

  • Analyze grant funding abstracts for potential anchoring bias
  • Understand hierarchical patterns in funding decisions
  • Process complex abstract text with only 27M parameters
  • Provide interpretable reasoning about funding patterns

Repository Structure

.
├── models/               # Model architecture (with register_buffer fix)
├── config/              # Training and inference configurations
├── dataset/             # Custom training data
├── PROJECT_TRACE.md     # Complete project documentation
├── Dockerfile           # Container deployment
└── startup.sh          # HF Spaces initialization

Training Details

  • Base Model: HRM (Hierarchical Reasoning Model) - 27M parameters
  • Training Data: Custom grant abstracts dataset
  • Training Duration: ~19 days on RunPod GPU infrastructure
  • Optimization: ACT (Adaptive Computation Time) loss with stablemax cross-entropy
  • Checkpoint: Abstract_optimizer_processed ACT-torch/HierarchicalReasoningModel_ACTV1

Usage

The trained model is deployed and available at:

Citation

If you use this work, please cite both the original HRM paper and this modification:

@article{original_hrm,
  title={Hierarchical Reasoning Model},
  author={Sapient Intelligence},
  year={2024},
  url={https://github.com/sapientinc/HRM}
}

License

This project maintains the same license as the original HRM repository (see LICENSE file).

Acknowledgments

  • Original HRM authors at Sapient Intelligence for the innovative architecture
  • RunPod for GPU infrastructure
  • Hugging Face for deployment platform

About

HRM (Hierarchical Reasoning Model) finetuning (grant abstracts dataset)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages