openai/gsm8k
Benchmark • Updated • 17.6k • 1.25M • 1.6k
How to use adimunot/mathnano-qwen1.5b-sft with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B")
model = PeftModel.from_pretrained(base_model, "adimunot/mathnano-qwen1.5b-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.
| 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).
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.
\boxed{...}.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
Base model
Qwen/Qwen2.5-1.5B