BTX24/qwen2_5_0_5b_turkish-mobile-actions
Qwen2.5 0.5B Turkish Mobile Action Router LoRA
Türkçe
Bu repo, Qwen/Qwen2.5-0.5B-Instruct modeli üzerine LoRA ile fine-tune edilmiş bir Türkçe mobil function-calling / action-router adapter içerir.
Modelin amacı, Türkçe doğal dil mobil komutlarını tek satırlık geçerli JSON function-call çıktısına dönüştürmektir. Bu model FunctionGemma special token formatını veya FunctionGemma tool_calls formatını kullanmaz. Çıktı doğrudan JSON router formatındadır.
Hedef Çıktı Formatı
Model yalnızca şu formatta JSON üretmelidir:
{"name":"tool_name","arguments":{...}}Örnek:
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}Sistem Mesajı
Sen Türkçe mobil komutları function call JSON formatına çeviren bir modelsin. Kullanıcıya açıklama yapma. Sadece geçerli JSON üret. JSON formatı şu olmalı: {"name":"tool_name","arguments":{...}}. Eğer bilgi eksikse ask_clarification kullan. Riskli işlemde request_confirmation kullan.Desteklenen Tool Listesi
set_alarmset_timercreate_remindersend_messagecall_contactopen_appchange_device_settingcreate_notestart_navigationsearch_webask_clarificationrequest_confirmation
Veri Seti
Model, birden fazla CSV/XLSX dosyasından birleştirilen Türkçe mobil function-calling veri seti ile eğitildi.
Beklenen kolonlar:
user_contenttool_nametool_arguments
Veri temizleme sürecinde şunlar yapıldı:
- Boş satırlar temizlendi.
- Duplicate satırlar silindi.
- Tool isimleri allowed tool listesine göre doğrulandı.
tool_argumentsalanı JSON olarak parse edildi.- Her tool için required argument alanları kontrol edildi.
- Eski/alternatif tool şemaları normalize edildi.
Örnek normalizasyonlar:
Kod ve Tekrarlanabilirlik
Projenin kaynak kodu ve Colab eğitim akışı GitHub üzerinde tutulmaktadır:
- GitHub repository: https://github.com/BoranT-3000/turkish-mobile-action-router
- Training notebook:
qwen_mobile_action_router_lora_colab.ipynb
Not: Notebook dosyası Hugging Face model reposunda Files and versions bölümüne yüklenebilir. Model kartında bu bölümün linklenmesi, eğitimin tekrar üretilebilirliğini artırır.
Veri Seti Boyutu
- Toplam temiz satır: 12854
- Train satırı: 11568
- Test satırı: 1286
Tool Dağılımı
Eğitim
Eğitim tipi: LoRA / PEFT adapter
Eğitim Sonuçları
Validation loss eğitim boyunca düzenli olarak düştü:

Evaluation
Fine-tuning öncesi 50 örnek üzerinde base model sonucu:
Fine-tuning sırasında callback ile 50 örnek üzerinde görülen en iyi sonuç:
both_accuracy, hem tool adının hem de argument JSON’unun birebir doğru olduğu örnek oranıdır. args_exact_accuracy oldukça katıdır; küçük format farkları bile yanlış sayılabilir.
Validasyon Değerlendirmesi
Fine-tuning öncesi değerlendirme 50 örnek üzerinde yapılmıştır. Fine-tuning sonrası değerlendirme tüm test seti olan 1286 örnek üzerinde yapılmıştır.
Fine-tuning sonrası hata analizi:
- Test örneği: 1286
- Hatalı veya exact match olmayan örnek: 219
- Hata dosyası:
errors_qwen_after_finetune.csv - Metrik dosyası:
qwen_eval_metrics.json
tool_accuracy, modelin doğru tool/fonksiyon adını seçme oranıdır. args_exact_accuracy, üretilen arguments JSON nesnesinin beklenen JSON ile birebir aynı olma oranıdır. both_accuracy, hem tool adının hem de argument JSON’unun birebir doğru olduğu örnek oranıdır. json_valid_rate, model çıktısının parse edilebilir geçerli JSON içerme oranıdır.
args_exact_accuracy ve both_accuracy oldukça katı metriklerdir. Küçük format farkları, alternatif ama semantik olarak doğru argument değerleri veya normalize edilmemiş tarih/saat ifadeleri yanlış sayılabilir.
Kullanım
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-0.5B-Instruct"
ADAPTER_ID = "BTX24/qwen2_5_0_5b_turkish-mobile-actions"
system_prompt = (
"Sen Türkçe mobil komutları function call JSON formatına çeviren bir modelsin. "
"Kullanıcıya açıklama yapma. Sadece geçerli JSON üret. "
"JSON formatı şu olmalı: {\"name\":\"tool_name\",\"arguments\":{...}}. "
"Eğer bilgi eksikse ask_clarification kullan. "
"Riskli işlemde request_confirmation kullan."
)
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_ID, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base, ADAPTER_ID)
model.eval()
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Yarın sabah 8'e alarm kur"},
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(
**inputs,
do_sample=False,
max_new_tokens=128,
pad_token_id=tokenizer.eos_token_id,
)
generated = output[0][inputs["input_ids"].shape[-1]:]
print(tokenizer.decode(generated, skip_special_tokens=True).strip())Beklenen çıktı stili:
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}Notlar ve Sınırlamalar
Bu model genel amaçlı bir sohbet asistanı değildir. Sadece Türkçe mobil komutları JSON action-router formatına çevirmek için eğitilmiştir.
Gerçek bir mobil otomasyon sisteminde model çıktısı doğrudan çalıştırılmamalıdır. Üretilen JSON mutlaka uygulama tarafında doğrulanmalı, özellikle mesaj gönderme, silme, ayar değiştirme veya geri dönüşü zor işlemler için kullanıcıdan açık onay alınmalıdır.
Qwen2.5 0.5B Turkish Mobile Action Router LoRA
English
This repository contains a LoRA adapter fine-tuned from Qwen/Qwen2.5-0.5B-Instruct for Turkish mobile function-calling / action-routing.
The goal of the model is to convert Turkish natural language mobile commands into a single-line valid JSON function-call output. This model does not use FunctionGemma special tokens or the FunctionGemma tool_calls format. It uses a direct JSON router format.
Target Output Format
The model should output only JSON in the following format:
{"name":"tool_name","arguments":{...}}Example:
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}System Prompt
Sen Türkçe mobil komutları function call JSON formatına çeviren bir modelsin. Kullanıcıya açıklama yapma. Sadece geçerli JSON üret. JSON formatı şu olmalı: {"name":"tool_name","arguments":{...}}. Eğer bilgi eksikse ask_clarification kullan. Riskli işlemde request_confirmation kullan.Supported Tools
set_alarmset_timercreate_remindersend_messagecall_contactopen_appchange_device_settingcreate_notestart_navigationsearch_webask_clarificationrequest_confirmation
Dataset
The model was trained on a Turkish mobile function-calling dataset merged from multiple CSV/XLSX files.
Expected columns:
user_contenttool_nametool_arguments
Cleaning steps included:
- Empty row removal
- Duplicate row removal
- Tool name validation
- JSON parsing for
tool_arguments - Required argument validation per tool
- Normalization of older or alternative tool schemas
Example normalizations:
Code and Reproducibility
The source code and Colab training workflow are available in the project GitHub repository:
- GitHub repository: https://github.com/BoranT-3000/turkish-mobile-action-router
- Training notebook:
qwen_mobile_action_router_lora_colab.ipynb
Note: The notebook can be uploaded to the Hugging Face model repository under Files and versions. Linking it from this model card helps make the training process reproducible.
Dataset Size
- Total clean rows: 12854
- Train rows: 11568
- Test rows: 1286
Tool Distribution
Training
Training type: LoRA / PEFT adapter
Training Results
Validation loss decreased steadily during training:

Evaluation
Base model result before fine-tuning on 50 samples:
Best callback result during fine-tuning on 50 samples:
both_accuracy means both the predicted tool name and the full argument JSON matched exactly. args_exact_accuracy is intentionally strict; small formatting differences may count as incorrect.
Validation
Before fine-tuning evaluation was run on 50 samples. After fine-tuning evaluation was run on the full test set of 1286 samples.
Post fine-tuning error analysis:
- Test samples: 1286
- Incorrect or non-exact-match samples: 219
- Error file:
errors_qwen_after_finetune.csv - Metrics file:
qwen_eval_metrics.json
tool_accuracy measures whether the model selected the correct tool/function name. args_exact_accuracy measures whether the generated arguments JSON object exactly matched the expected JSON. both_accuracy requires both the tool name and the full argument JSON to match exactly. json_valid_rate measures whether the model output contains parseable valid JSON.
args_exact_accuracy and both_accuracy are intentionally strict metrics. Small formatting differences, semantically equivalent argument values, or unnormalized date/time expressions may still count as incorrect.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-0.5B-Instruct"
ADAPTER_ID = "BTX24/qwen2_5_0_5b_turkish-mobile-actions"
system_prompt = (
"Sen Türkçe mobil komutları function call JSON formatına çeviren bir modelsin. "
"Kullanıcıya açıklama yapma. Sadece geçerli JSON üret. "
"JSON formatı şu olmalı: {\"name\":\"tool_name\",\"arguments\":{...}}. "
"Eğer bilgi eksikse ask_clarification kullan. "
"Riskli işlemde request_confirmation kullan."
)
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_ID, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base, ADAPTER_ID)
model.eval()
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Yarın sabah 8'e alarm kur"},
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(
**inputs,
do_sample=False,
max_new_tokens=128,
pad_token_id=tokenizer.eos_token_id,
)
generated = output[0][inputs["input_ids"].shape[-1]:]
print(tokenizer.decode(generated, skip_special_tokens=True).strip())Expected output style:
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}Notes and Limitations
This model is not a general-purpose chat assistant. It is trained only to convert Turkish mobile commands into JSON action-router outputs.
In a real mobile automation system, model outputs should not be executed directly. The generated JSON must be validated by the application layer, and risky actions such as sending messages, deleting data, changing settings, or irreversible operations should require explicit user confirmation.
