FinAgent-TR Qwen3-8B LoRA

Qwen3-8B base model üzerinde FinAgent-TR dataset ile fine-tune edilmiş Türkçe LoRA adapter'ıdır. Finansal okuryazarlık soruları, tool selection, tool call generation ve tool output'a dayalı response generation için eğitildi.

Installation

pip install -U unsloth peft transformers accelerate bitsandbytes

Inference

import torch
from unsloth import FastLanguageModel

MODEL_ID = "Dbmaxwell/finagent-tr-qwen3-8b-unsloth-lora"

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name=MODEL_ID,
    max_seq_length=1024,
    load_in_4bit=True,
)

FastLanguageModel.for_inference(model)

messages = [
    {
        "role": "system",
        "content": "Türkçe finansal okuryazarlık asistanısın. Net ve dayanaklı yanıt ver.",
    },
    {
        "role": "user",
        "content": "50.000 TL yıllık yüzde 10 bileşik faizle iki yıl sonunda kaç TL olur?",
    },
]

input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    enable_thinking=False,
    return_tensors="pt",
).to(model.device)

with torch.inference_mode():
    output_ids = model.generate(
        input_ids,
        max_new_tokens=256,
        do_sample=True,
        temperature=0.7,
        top_p=0.8,
        top_k=20,
        pad_token_id=tokenizer.eos_token_id,
    )

answer = tokenizer.decode(
    output_ids[0, input_ids.shape[-1]:],
    skip_special_tokens=True,
)

print(answer)

Tool Calling

Tool'lar model tarafından çalıştırılmaz. Model tool call üretir; tool execution ve tool output'un conversation'a tool message olarak eklenmesi agent runtime'ın sorumluluğundadır.

Tool schema'ları Qwen3 chat template'ine tools parametresiyle verilir:

tools = [
    {
        "type": "function",
        "function": {
            "name": "tefas_price",
            "description": "TEFAS fon fiyatını getirir.",
            "parameters": {
                "type": "object",
                "properties": {
                    "as_of": {
                        "type": "string",
                        "description": "ISO tarih",
                    },
                    "range": {
                        "type": "string",
                        "enum": ["narrow", "wide"],
                    },
                },
                "additionalProperties": False,
            },
        },
    }
]

messages = [
    {
        "role": "system",
        "content": "Güncel finans verisi gereken sorularda uygun aracı kullan.",
    },
    {
        "role": "user",
        "content": "Fonun 2025-01-15 tarihindeki fiyatını kontrol eder misin?",
    },
]

input_ids = tokenizer.apply_chat_template(
    messages,
    tools=tools,
    tokenize=True,
    add_generation_prompt=True,
    enable_thinking=False,
    return_tensors="pt",
).to(model.device)

Bu input'tan sonra standard model.generate() flow kullanılabilir. Üretilen tool name ve arguments, execution öncesinde application layer'da validate edilmelidir.

Training

  • Base model: Qwen3-8B, Unsloth 4-bit sürümü
  • Dataset: Dbmaxwell/finagent-tr
  • Dataset size: 1.000 validated episode
  • Split: 800 train, 100 validation, 100 test
  • Method: 4-bit QLoRA
  • LoRA rank: 8
  • LoRA alpha: 16
  • LoRA dropout: 0.1
  • Target modules: q_proj, k_proj, v_proj, o_proj
  • Max sequence length: 1.024 token
  • Epochs: 1
  • Learning rate: 3e-5
  • Loss masking: yalnızca assistant tool calls ve responses

Evaluation

Evaluation, 100 test episode ve 5.836 supervised assistant token üzerinde yapıldı. Base model ve fine-tuned model aynı tokenizer, 4-bit quantization, loss masking ve test split ile ölçüldü. Base-model baseline için yalnızca LoRA adapter geçici olarak disable edildi.

Model Test loss Perplexity
Qwen3-8B base 3.1655 23.70
FinAgent-TR fine-tuned LoRA 1.5700 4.81

Fine-tuned model, base model'e göre:

  • Test loss: yüzde 50,4 reduction
  • Perplexity: yüzde 79,7 reduction

Bu sonuç teacher-forced next-token prediction ve in-distribution generalization ölçümüdür. Tek başına end-to-end agent accuracy anlamına gelmez.

Planned Behavior Evaluation

  • Tool-name exact match
  • Tool-argument JSON validity
  • Tool-argument accuracy
  • Tool gerekmeyen sorularda unnecessary tool-call rate
  • Tool output'a grounded final-answer accuracy
  • Clarification behavior
  • Out-of-distribution, human-written finans soruları

Limitations

  • Training dataset ağırlıklı olarak synthetic ve validated agent episode'larından oluşur.
  • Model internete veya gerçek finans tool'larına kendiliğinden bağlanmaz.
  • Tool execution için external agent runtime gerekir.
  • Güncel fiyat, mevzuat ve piyasa sorularında external data source kullanılmadan üretilen responses güncelliğini yitirmiş olabilir.
  • Generated outputs yatırım tavsiyesi değildir.
  • Generation-based behavior benchmark tamamlanmadan production-quality iddiası olarak yorumlanmamalıdır.

Dataset

Training dataset: Dbmaxwell/finagent-tr

License

Bu adapter Apache 2.0 license altında paylaşıldı. Base model license için Qwen3-8B model card sayfasını inceleyin.

Downloads last month
35
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train Dbmaxwell/finagent-tr-qwen3-8b-unsloth-lora