CoolFace
Modelpublic

BTX24/qwen2_5_0_5b_turkish-mobile-actions

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
1likes16downloads
Model Card

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:

json
{"name":"tool_name","arguments":{...}}

Örnek:

json
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}

Sistem Mesajı

text
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_alarm
  • —set_timer
  • —create_reminder
  • —send_message
  • —call_contact
  • —open_app
  • —change_device_setting
  • —create_note
  • —start_navigation
  • —search_web
  • —ask_clarification
  • —request_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_content
  • —tool_name
  • —tool_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_arguments alanı JSON olarak parse edildi.
  • —Her tool için required argument alanları kontrol edildi.
  • —Eski/alternatif tool şemaları normalize edildi.

Örnek normalizasyonlar:

Eski ToolYeni Tool
toggle_settingchange_device_setting
make_callcall_contact
add_remindercreate_reminder
navigate_tostart_navigation
get_weathersearch_web
play_musicsearch_web
create_calendar_eventcreate_reminder
unsupported/risky actionsrequest_confirmation

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ı

ToolSatır
ask_clarification1686
call_contact1327
change_device_setting1455
create_note666
create_reminder663
open_app1251
request_confirmation206
search_web901
send_message1717
set_alarm879
set_timer1141
start_navigation962

Eğitim

Eğitim tipi: LoRA / PEFT adapter

ParametreDeğer
Base modelQwen/Qwen2.5-0.5B-Instruct
Epoch3
Learning rate0.0002
Max length384
Train batch size2
Gradient accumulation8

Eğitim Sonuçları

Validation loss eğitim boyunca düzenli olarak düştü:

StepTraining LossValidation Loss
2000.3124240.295018
4000.2510030.246801
6000.2275140.225656
8000.1940270.214237
10000.2040970.204993
12000.1841930.197630
14000.1822490.191827
16000.1547060.191181
18000.1549850.188500
20000.1529070.187198
21690.1517160.186988

Training and Evaluation Loss

Evaluation

Fine-tuning öncesi 50 örnek üzerinde base model sonucu:

MetricBefore Fine-tuning
JSON Valid Rate0.96
Tool Accuracy0.00
Args Exact Accuracy0.00
Both Accuracy0.00

Fine-tuning sırasında callback ile 50 örnek üzerinde görülen en iyi sonuç:

MetricBest Callback Result
JSON Valid Rate1.00
Tool Accuracy1.00
Args Exact Accuracy0.92
Both Accuracy0.92

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.

MetricBefore Fine-tuningAfter Fine-tuning
Samples501286
JSON Valid Rate0.96000.9992
Tool Accuracy0.00000.9743
Args Exact Accuracy0.00000.8297
Both Accuracy0.00000.8297

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

python
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:

json
{"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:

json
{"name":"tool_name","arguments":{...}}

Example:

json
{"name":"set_alarm","arguments":{"time":"08:00","date":"tomorrow","label":null}}

System Prompt

text
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_alarm
  • —set_timer
  • —create_reminder
  • —send_message
  • —call_contact
  • —open_app
  • —change_device_setting
  • —create_note
  • —start_navigation
  • —search_web
  • —ask_clarification
  • —request_confirmation

Dataset

The model was trained on a Turkish mobile function-calling dataset merged from multiple CSV/XLSX files.

Expected columns:

  • —user_content
  • —tool_name
  • —tool_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:

Old ToolNew Tool
toggle_settingchange_device_setting
make_callcall_contact
add_remindercreate_reminder
navigate_tostart_navigation
get_weathersearch_web
play_musicsearch_web
create_calendar_eventcreate_reminder
unsupported/risky actionsrequest_confirmation

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

ToolRows
ask_clarification1686
call_contact1327
change_device_setting1455
create_note666
create_reminder663
open_app1251
request_confirmation206
search_web901
send_message1717
set_alarm879
set_timer1141
start_navigation962

Training

Training type: LoRA / PEFT adapter

ParameterValue
Base modelQwen/Qwen2.5-0.5B-Instruct
Epochs3
Learning rate0.0002
Max length384
Train batch size2
Gradient accumulation8

Training Results

Validation loss decreased steadily during training:

StepTraining LossValidation Loss
2000.3124240.295018
4000.2510030.246801
6000.2275140.225656
8000.1940270.214237
10000.2040970.204993
12000.1841930.197630
14000.1822490.191827
16000.1547060.191181
18000.1549850.188500
20000.1529070.187198
21690.1517160.186988

Training and Evaluation Loss

Evaluation

Base model result before fine-tuning on 50 samples:

MetricBefore Fine-tuning
JSON Valid Rate0.96
Tool Accuracy0.00
Args Exact Accuracy0.00
Both Accuracy0.00

Best callback result during fine-tuning on 50 samples:

MetricBest Callback Result
JSON Valid Rate1.00
Tool Accuracy1.00
Args Exact Accuracy0.92
Both Accuracy0.92

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.

MetricBefore Fine-tuningAfter Fine-tuning
Samples501286
JSON Valid Rate0.96000.9992
Tool Accuracy0.00000.9743
Args Exact Accuracy0.00000.8297
Both Accuracy0.00000.8297

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

python
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:

json
{"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.