Qwen3-1.7B-Base · Calc-gsm8k tool-calling SFT (40 steps)
Qwen/Qwen3-1.7B-Base after a short SFT (40 steps) that teaches it to think in <think> and call a
calculator tool for every arithmetic step, using the standard Qwen3 tool-calling chat format. The final
answer is given as <answer>N</answer>.
This is the SFT stage only. It was the starting checkpoint for a follow-up GRPO run (Dr. GRPO, no KL), which raised accuracy much further (see the results below).
Training
| Base | Qwen/Qwen3-1.7B-Base |
| Data | MU-NLPC/Calc-gsm8k train (7,273): each <gadget> step turned into an assistant turn <think>step</think> + <tool_call>, each <output> into a tool turn, <result> into <answer>N</answer> |
| Method | TRL SFTTrainer, LoRA r=32 / alpha=64 on all linear layers, assistant-only loss |
| Steps | 40 × batch 16 (8 × grad-accum 2) = 640 examples, lr 2e-4, max length 2048, seed 42 |
| Special tokens | Every format tag is one token. <answer>/</answer> were added on spare embedding rows. The chat/tool tag embedding rows (untrained in the base model) were trained too (lr 1e-3, tied lm_head) |
| Output | LoRA merged into the base weights; bf16 safetensors; tokenizer has the training chat template and `< |
| Loss | train 0.413 (final step 0.264), eval 0.261 |
The step count was picked from a 20–100 step sweep. At 40 steps, proper tool use reaches 94% and stays flat after that.
Results
Validation (200 questions × 4 samples, T=1.0):
| SFT steps | accuracy | proper tool use | every step via calculator | format ok |
|---|---|---|---|---|
| 0 (base) | 12.5% | 0% | 0% | 0% |
| 40 (this model) | 47.0% | 94.0% | 76.0% | 95.0% |
Test sets (pass@1 / pass@16):
| Model | Calc-gsm8k pass@1 | Calc-gsm8k pass@16 | gsm-hard pass@1 | gsm-hard pass@16 |
|---|---|---|---|---|
| Qwen3-1.7B-Base, tool prompt | 28.3% | 92.9% | 12.1% | 54.4% |
| Base + SFT 40 (this model) | 39.6% | 89.5% | 22.8% | 66.0% |
| Base + SFT 40 + GRPO 250 | 76.7% | 96.4% | 49.5% | 74.5% |
Format
System prompt used in training:
You are a careful math assistant. Solve the problem step by step. Think inside <think></think> and use the calculator tool for every arithmetic operation: reason about the step, call the tool, then continue from its result. When you are done, give the final numeric answer as <answer>number</answer>.
Each assistant turn is either a tool call or the final answer:
<|im_start|>assistant
<think>
Alex had 7 * 8 =
</think>
<tool_call>
{"name": "calculator", "arguments": {"expression": "7*8"}}
</tool_call><|im_end|>
<|im_start|>user
<tool_response>
56
</tool_response><|im_end|>
<|im_start|>assistant
<think>
...
</think>
<answer>34</answer><|im_end|>
The calculator accepts numbers, + - * /, parentheses and unary sign (no **). Run a multi-turn loop:
generate until <|im_end|>, execute any <tool_call>, append the <tool_response>, and repeat until
<answer> appears.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "ichovpanTT/qwen3-1.7b-calc-gsm8k-sft40"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype="bfloat16", device_map="auto")
tools = [{"type": "function", "function": {
"name": "calculator",
"description": "Evaluate an arithmetic expression.",
"parameters": {"type": "object", "properties": {"expression": {"type": "string"}}, "required": ["expression"]},
}}]
messages = [
{"role": "system", "content": "You are a careful math assistant. Solve the problem step by step. Think inside <think></think> and use the calculator tool for every arithmetic operation: reason about the step, call the tool, then continue from its result. When you are done, give the final numeric answer as <answer>number</answer>."},
{"role": "user", "content": "A shop sells pens at $3 each. How much do 17 pens cost?"},
]
ids = tok.apply_chat_template(messages, tools=tools, add_generation_prompt=True, enable_thinking=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512)
print(tok.decode(out[0][ids.shape[1]:]))
Limitations
This model is a short SFT made to teach the format, not to maximize accuracy. It is trained only on
grade-school arithmetic word problems with a single calculator tool, and it is not a general assistant.