MathNano — Qwen2.5-1.5B math solver (SFT)

A LoRA adapter that turns Qwen2.5-1.5B into a step-by-step math solver that ends every answer with \boxed{...}. This is the shipped model of the MathNano project — built end-to-end on a single RTX 4090 for ~£13.

Results (n=200 per benchmark)

Benchmark Accuracy
GSM8K 39.0%
MATH 40.0%

MATH by level: L1 66.7% · L2 56.8% · L3 41.5% · L4 34.1% · L5 18.0%. Scored with a verifiable answer-checker (boxed/#### extraction + numeric/symbolic equivalence).

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

tok = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B")
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B", torch_dtype="auto")
model = PeftModel.from_pretrained(model, "adimunot/mathnano-qwen1.5b-sft")

msgs = [
    {"role": "system", "content": "You are a careful mathematician. Solve the problem step by step, then give the final answer in \\boxed{}."},
    {"role": "user", "content": "If 5x - 3 = 12, what is the value of 5x + 3?"},
]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
ids = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=384, eos_token_id=tok.convert_tokens_to_ids("<|im_end|>"))
print(tok.decode(out[0, ids.input_ids.shape[1]:], skip_special_tokens=True))

Tip: set the generation eos_token_id to <|im_end|> so it stops right after the answer.

Training

  • Base: Qwen2.5-1.5B. Method: LoRA SFT (r=16, all-linear), 1 epoch, ~119k examples.
  • Data: GSM8K train + Hendrycks MATH (train) + a 100k subset of OpenMathInstruct-2, all reformatted to a step-by-step solution ending in \boxed{...}.
  • Final SFT token accuracy ~87%.

Limitations

  • 1.5B model: arithmetic slips and weak performance on hard (L4–L5) competition problems.
  • Math-only assistant, English, not a general chatbot.
  • A subsequent GRPO run degraded this model (corrupted reward from non-stopping rollouts) — see the project's RESULTS.md for the post-mortem. Use this SFT checkpoint, not the GRPO one.

Project, code, and full write-up: https://github.com/adimunot21/mathnano

Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for adimunot/mathnano-qwen1.5b-sft

Adapter
(450)
this model

Datasets used to train adimunot/mathnano-qwen1.5b-sft