Downloads · 30 days
22
13% of all-time downloads
HAD653/qwen3-1.7b-magistral-math
qwen3-1.7b-magistral-math is a text generation model from HAD653. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
[](https://www.apache.org/licenses/LICENSE-2.0)
Downloads · 30 days
22
13% of all-time downloads
All-time downloads
174
Public
Parameters
1.7B
3.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.4 GB · 100%
From the Hugging Face model README
“Magistral” here refers to a lecture-style (magistral) math reasoning supervision. This is an independent community model, not affiliated with or endorsed by Mistral
Qwen3-1.7B Magistral Math is a math-specialized fine-tune of
unsloth/Qwen3-1.7B-Base,
trained in full BF16 on a compact, high-quality chain-of-thought dataset:
Data: HAD653/GSM8K-OpenMath-MathReason-13k
– 13.9k grade-school & early high-school word problems with structured CoT.
Goal: a 1.7B model that reliably solves GSM8K / OpenMath-style problems with clear step-by-step reasoning.
Answer format:
Problem:
...
Reasoning:
...
Answer:
<final numeric answer>
unsloth/Qwen3-1.7B-Basetorch_dtype=torch.bfloat16 recommended).transformers, vLLM, TGI.This repo stores full fine-tuned weights (no LoRA, no adapters).
The model is fine-tuned on:
Dataset: HAD653/GSM8K-OpenMath-MathReason-13k
Size: 13,857 samples.
Fields:
question: natural-language math word problem.
cot: chain-of-thought solution with 3 blocks:
Problem:Reasoning:Answer:final_answer: canonical numeric answer (string).
The dataset focuses on easy–medium difficulty:
It is deliberately aimed at what a 1–3B model can realistically master.
Fine-tuning was done with Unsloth + TRL on a single RTX 4090, using full BF16 finetuning (no LoRA).
Base: unsloth/Qwen3-1.7B-Base
Sequence length: 2048
Epochs: 2
Batching:
per_device_train_batch_size = 2gradient_accumulation_steps = 8Optimizer / schedule:
learning_rate = 7e-5warmup_ratio = 0.05weight_decay = 0.01Precision / memory:
dtype = bfloat16gradient_checkpointing = TrueEach example is converted to a single text field:
### Instruction:
{question}
### Response:
{cot}</s>
Where </s> is the tokenizer EOS token.
Adding the EOS token at the end of the target helps the model learn when to stop, and largely removes pathological loops like:
Answer:
36
Answer:
36
Answer:
36
...
You are a math reasoning assistant.
For every question, answer in exactly this format:
Problem:
<restate the problem in your own words>
Reasoning:
<step-by-step reasoning showing all intermediate steps>
Answer:
<final numeric answer only, on its own line>
Do not add any extra commentary before or after the answer.
Do not repeat the answer multiple times.
Stop after writing the final answer.
For single-turn usage:
### Instruction:
{question}
### Response:
The model will then generate:
Problem:
...
Reasoning:
...
Answer:
<number>
For math, use low-temperature decoding:
temperature: 0.0 – 0.2top_p: 0.9top_k: 20–40 (optional)repetition_penalty: 1.05 – 1.10max_new_tokens: 256–512 for long CoTfrom transformers import AutoTokenizer, AutoModelForCausalLM
MODEL_NAME = "HAD653/qwen3-1.7b-magistral-math"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
torch_dtype="auto", # will be bf16 if supported
device_map="auto",
)
def format_prompt(question: str) -> str:
return f"### Instruction:\n{question}\n\n### Response:\n"
question = "Albert buys 2 large pizzas and 2 small pizzas. A large pizza has 16 slices and a small pizza has 8 slices. If he eats it all, how many pieces does he eat that day?"
prompt = format_prompt(question)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False, # greedy is usually best for math
repetition_penalty=1.05,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The model is a standard qwen3 architecture checkpoint, so it should work
out-of-the-box with any backend that supports Qwen3 via transformers>=4.51.
Please also ensure there is no data leakage if you evaluate on GSM8K/OpenMath-derived benchmarks.
HAD653/qwen3-1.7b-magistral-math-ggufIf you use this model in your work, please cite:
@misc{had653_qwen3_magistral_math_2025,
author = {HAD653},
title = {Qwen3-1.7B Magistral Math: A 1.7B Math Reasoning Model with Magistral Chain-of-Thought},
year = {2025},
howpublished = {\url{https://huggingface.co/HAD653/qwen3-1.7b-magistral-math}},
note = {Fine-tuned on GSM8K + OpenMath MathReason 13k with full BF16 supervision.}
}