Qwen3-1.7B-Base · Calc-gsm8k tool-calling SFT (40 steps)
fine-tuning the model for precise computations via tools
2 min readupdated
This model is the result of a short SFT (supervised fine-tuning) of the base Qwen/Qwen3-1.7B-Base model on the Calc-gsm8k dataset. The training teaches the AI model to reason inside tags and call the built-in calculator tool for every arithmetic operation. The output is an assistant that solves math problems step by step and provides the final answer inside tags. The model serves as an intermediate stage before more complex GRPO training and is suitable for developers exploring how LLMs work with external tools (tool-calling).
Key features
- Trained in 40 steps using LoRA (a small adapter added to the base model for weight adaptation) on linear layers.
- Uses a special chat format with calculator tool calls and reasoning tags.
- Achieves 94% correct tool usage on the validation set.
- Weights are merged into the base model and saved in bfloat16 safetensors format.
What you can do
- Apply it in a custom pipeline for solving text math problems with calculation verification via code.
- Set up a multi-step generation loop with interception and execution of
calculatortool calls. - Use it as a starting point for your own experiments with GRPO or other reinforcement learning methods.
Example
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 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 number."},
{"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]:]))
Read more
DetailsBenchmarks: Calc-gsm8k pass@1 — 39.6%, gsm-hard pass@1 — 22.8%
Requirements: transformers library, bfloat16 support
Training data: 7,273 examples from MU-NLPC/Calc-gsm8k
Limitations: the model is narrowly specialized in school arithmetic problems with a single tool and is not a universal assistant.










Comments