Downloads · 30 days
72
73% of all-time downloads
thealper2/qwen2.5-0.5b-gsm8k-tr-lora
qwen2.5-0.5b-gsm8k-tr-lora is a text generation model from thealper2. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter for Qwen/Qwen2.5-0.5B-Instruct, fine-tuned on ytu-ce-cosmos/gsm8ktr for Turkish grade-school math word problems. The model produces a step-by-step Turkish solution followed by the final numeric answer.
Downloads · 30 days
72
73% of all-time downloads
All-time downloads
98
Public
Repo size
46.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors35.2 MB · 75%
From the Hugging Face model README
LoRA adapter for Qwen/Qwen2.5-0.5B-Instruct, fine-tuned on
ytu-ce-cosmos/gsm8k_tr
for Turkish grade-school math word problems. The model produces a step-by-step
Turkish solution followed by the final numeric answer.
This repository contains the PEFT adapter only (rank-16 LoRA); the base model is loaded separately at inference time.
import torch
from peft import PeftModel
from 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.
| 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.
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.
| 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.
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.
| 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.
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.