This repository hosts the fine-tuned LoRA & Direct Preference Optimization (DPO) adapter weights for Qwen2.5-1.5B-Instruct, specialized in autonomous financial tool execution, banking API schema validation, and guardrail enforcement.
| Evaluation Metric | Zero-Shot Base | After SFT LoRA | After DPO Alignment |
|---|---|---|---|
| Tool Selection Accuracy | 42.0% | 94.0% | 98.0% |
| JSON Schema Validity | 68.0% | 98.0% | 100.0% |
| Argument Extraction Precision | 54.0% | 91.5% | 96.5% |
| Out-of-Domain Refusal Rate | 20.0% | 85.0% | 100.0% |
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "Qwen/Qwen2.5-1.5B-Instruct"
adapter_repo = "arfeen2006/Fine-tuning-model-on-finance-domain"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base, adapter_repo)
messages = [
{"role": "system", "content": "You are a banking tool-calling engine. Return raw JSON tool invocations."},
{"role": "user", "content": "Transfer $250 from checking account ACC-101 to savings account ACC-202."}
]
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():
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.0)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
adapter_model.safetensors 74 MBsft/adapter_model.safetensors 74 MBQwen/Qwen2.5-1.5B-Instruct