A tiny GPT-style causal language model (236,928 parameters) trained on SAT-level
math problems. Built entirely in NumPy with no PyTorch dependency. Demonstrates
the full fine-tuning pipeline: tokenization, causal attention, AdamW, and
cross-entropy loss on a byte-level vocabulary.
1from modeling_mathstral_nano import MathstralNano
2
3model = MathstralNano.from_pretrained(".")
4print(model)
5# MathstralNano(4L 8H 64d params=236,928)
6
7# Raw generation
8response = model.generate("Problem: If 2x + 5 = 13, find x. Solution:")
9print(response)
10
11# Convenience wrapper (formats the prompt automatically)
12response = model.solve("If 3x + 7 = 22, find x.")
13print(response)