MiniReasoner: A lightweight reasoning model for arithmetic
2 min readupdated
MiniReasoner is a compact 32M-parameter decoder-only language model built from scratch in PyTorch. It was pre-trained on the SimpleStories dataset and fine-tuned using chain-of-thought prompting for step-by-step math problem solving. The model provides step-by-step solutions to problems while retaining creative text generation skills. This new release will be useful for researchers and developers studying the training of small language models with a focus on logic.
Key features
- RoPE architecture: Uses a decoder-only transformer with rotary position embedding and tied embeddings.
- Reasoning accuracy: Achieves 97.35% accuracy on an arithmetic test set thanks to chain-of-thought fine-tuning.
- Retention of core skills: Maintains smooth story generation fluency by keeping 10% of the original dataset during training.
- Compact size: The model weighs about 122 MB, making it easy to run on modest computing resources.
What you can do
- Solve math problems: Integrate the model into Python scripts for automatic calculation of complex problems with mixed operations.
- Generate stories: Use the model to continue short English stories in the style of the SimpleStories dataset.
- Explore the architecture: Examine the custom tokenization code and training process in the project repository.
Example
from huggingface_hub import hf_hub_download
import importlib.util
import sys
mod_path = hf_hub_download("sampath017/MiniReasoner", "modeling_minireasoner.py")
spec = importlib.util.spec_from_file_location("modeling_minireasoner", mod_path)
mr = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = mr
spec.loader.exec_module(mr)
reasoner = mr.MiniReasoner.from_pretrained("sampath017/MiniReasoner")
print(reasoner.solve("What is -95 * 672?"))
Read more
DetailsBenchmarks: 97.35% strict / 97.42% exact accuracy on 6,002 arithmetic_v3 tests.
Context window: 1,024 tokens.
Limitations: Trained on integers up to 3 digits; complex 4-digit problems and open-ended dialogue are outside its scope.










Comments