What we trained
A two-stage, sequential pipeline:
- Thinking-mode LoRA SFT — distil DeepSeek-R1-style long chain-of-thought
into Qwen3-1.7B. Assistant turns contain an explicit
<think>…</think> trace
ending in \boxed{}. Trained on Dicksonycx/oumi_math_4096 (~114.5k rows
derived from MetaMathQA-R1).
- GRPO (GSPO / DAPO) — reinforcement learning with a verifiable reward on
top of the merged SFT model: sequence-level importance sampling (GSPO),
loss_type=dapo, beta=0 (no KL), on a difficulty-filtered prompt set.
The \boxed{} answer contract is enforced by (1) the SFT system prompt, (2) all
SFT targets ending in \boxed{}, and (3) a GRPO boxed-format penalty.
Inference / decoding
Thinking mode is ON — the model emits a <think>…</think> block before the
final \boxed{}. Values below are exactly those in generation_config.json:
Table with columns: param, value| param | value |
|---|
do_sample | true |
temperature | 0.6 |
top_k | 20 |
top_p | 0.95 |
max_new_tokens | not set in generation_config.json; the course CI uses 4096 (nightly) / 16384 (final grading) |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer repo = "cs-552-2026-ma-que/math_model"tok = AutoTokenizer.from_pretrained(repo)model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="auto", device_map="auto") messages = [{"role": "user", "content": "What is the smallest prime greater than 100?"}]text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tok(text, return_tensors="pt").to(model.device)out = model.generate(**inputs, max_new_tokens=4096)print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Training data
Table with columns: Stage, Data, Size| Stage | Data | Size |
|---|
| SFT | Dicksonycx/oumi_math_4096 (← MetaMathQA-R1) | ~114.5k rows |
| GRPO | difficulty-filtered math prompt set | — |
Evaluation (scored only, never trained on): MATH-500 and openr1_500
(built from OpenR1-Math-220k).
Notes
- Training was done on a single NVIDIA A100 40 GB (EPFL RCP cluster).
- SFT: LoRA r=256 (α/r=1, all 7 q/k/v/o/gate/up/down projections), lr 2e-4
cosine, 2 epochs, 6144-token packed sequences,
assistant_only_loss,
Liger fused cross-entropy + FlashAttention-2 + gradient checkpointing.
- GRPO: LoRA r=64, GSPO + DAPO (
beta=0, epsilon=0.2, clip-higher); reward
= correctness (+2.0) − missing-\boxed{} penalty (−1.5) + cosine length-shaping
- soft-overlong penalty; lr 5e-6.
- No credentials are stored;
HF_TOKEN / WANDB_API_KEY are read from the
environment.