Usage
import torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer BASE = "Qwen/Qwen2.5-0.5B-Instruct"ADAPTER = "thealper2/qwen2.5-0.5b-gsm8k-tr-lora" tokenizer = AutoTokenizer.from_pretrained(ADAPTER)model = AutoModelForCausalLM.from_pretrained(BASE, dtype=torch.bfloat16, device_map="auto")model = PeftModel.from_pretrained(model, ADAPTER)model.eval() messages = [ {"role": "system", "content": 'Sen matematik problemlerini cozen bir asistansin. Problemi adim adim Turkce olarak coz ve sonunda nihai cevabi acikca belirt.'}, {"role": "user", "content": "Ali'nin 5 elmasi vardir. 3 elma daha alirsa kac elmasi olur?"},]prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device) output = model.generate(**inputs, max_new_tokens=400, do_sample=False)print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
The system prompt above is the one used during training; keeping it improves
output-format consistency.
Training data
Table | |
|---|
| Dataset | ytu-ce-cosmos/gsm8k_tr |
| Rows | 8792 (single train split upstream) |
| Split | 7870 train / 876 validation, 10% held out, seed 42 |
| Duplicates removed | 0 |
| Format | free-form Turkish solutions; no #### <answer> marker and no <<...>> calculator annotations |
Examples are rendered with the official Qwen2.5 chat template as
system / user / assistant turns. The reference solution is used verbatim; no
reasoning steps were rewritten, simplified or synthesised.
Training procedure
Loss is computed on assistant tokens only: prompt tokens are set to -100 via
prompt-prefix masking, so the model is not trained to reproduce the question.
Table with columns: Hyperparameter, Value| Hyperparameter | Value |
|---|
| Method | LoRA (PEFT), base weights frozen |
| LoRA rank / alpha / dropout | 16 / 32 / 0.05 |
| LoRA bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Trainable parameters | 8.80M / 502.83M (1.75%) |
| Learning rate | 0.0002 |
| Scheduler | cosine, warmup ratio 0.03 |
| Weight decay | 0.01 |
| Gradient clipping | 1.0 |
| Epochs | 3.0 |
| Effective batch size | 16 (4 x 4 accumulation) |
| Max sequence length | 640 tokens |
| Precision | torch.bfloat16 |
| Best checkpoint | selected on validation loss |
lm_head is excluded from the adapter because Qwen2.5-0.5B ties its input and
output embeddings.
Sequence length was set from the measured token distribution under the chat
template (mean 265, median 253, p90 399, p95 456, p99 589, max 916). At 640
tokens, 99.48% of examples
fit; the remaining over-length examples are dropped rather than truncated,
because truncation would remove the concluding sentence that states the final
answer.
Evaluation
Greedy decoding (do_sample=False, max_new_tokens=400) on
500 held-out validation examples. Both rows are scored on exactly the same
examples with the same answer extractor.
Table with columns: Model, Validation Loss, Perplexity, Answer Accuracy| Model | Validation Loss | Perplexity | Answer Accuracy |
|---|
Base Qwen/Qwen2.5-0.5B-Instruct | 1.1266 | 3.09 | 5.00% |
| This model (LoRA fine-tuned) | 0.6776 | 1.97 | 15.80% |
Answer accuracy compares the final numeric answer extracted from the
generation against the one extracted from the Turkish reference solution, with
tolerance 1e-4. The extractor resolves \boxed{}, explicit Cevap: markers,
LaTeX fractions, percentages, and both Turkish and English decimal/thousands
conventions.
Perplexity is computed over assistant tokens only. It measures fit to the
reference solution style, not mathematical correctness -- a model can lower it
by imitating phrasing while still computing wrong answers. Answer accuracy is
the metric that speaks to reasoning.
Limitations
- Scope. Trained only on GSM8K-style grade-school word problems. Performance
here does not imply general mathematical reasoning: no algebra, geometry,
proofs, symbolic manipulation or multi-domain math is covered.
- Model capacity. At 0.5B parameters, multi-step arithmetic remains
error-prone. Expect arithmetic slips on longer chains.
- Label noise. Roughly 21% of
gsm8k_tr solutions reach a different final answer than the corresponding original English GSM8K item (measured on 4592 uniquely alignable rows). Accuracy is measured against the Turkish
reference, which is what the model is trained to reproduce, so the reported
number reflects agreement with this dataset rather than with original GSM8K.
- Language. Trained and evaluated in Turkish only.
- No verification. Output is not checked by a calculator or solver. Do not
rely on it for consequential calculations.