Downloads · 30 days
12
26% of all-time downloads
navenduk75/qwen2.5-3b-function-calling-lora
qwen2.5-3b-function-calling-lora is a text generation model from navenduk75. Use it when you need the model to write or continue text. It is set up for peft.
LoRA adapter fine-tuned on top of Qwen/Qwen2.5-3B-Instruct for structured function/tool calling. Trained with TRL SFTTrainer and PEFT LoRA (r=16, loraalpha=32, targeting qproj/vproj).
Downloads · 30 days
12
26% of all-time downloads
All-time downloads
46
Public
Repo size
26.2 MB
Likes
1
Public
Click a slice to open those files.
.safetensors14.8 MB · 56%
From the Hugging Face model README
LoRA adapter fine-tuned on top of Qwen/Qwen2.5-3B-Instruct
for structured function/tool calling. Trained with TRL SFTTrainer and
PEFT LoRA (r=16, lora_alpha=32, targeting q_proj/v_proj).
This is an adapter, not a merged model — you need the base model plus peft to load it.
get_weather(location, unit)get_news(topic, limit)calculate(expression)The model expects a custom pseudo-chat format (not the standard HF chat template):
<|system|>
{system prompt}
<|tools|>
{tools.json as a JSON array}
<|user|>
{user message}
<|assistant|>
The model completes the <|assistant|> block with either:
{"name": "...", "arguments": {...}} (it was also trained on code-fenced, <tool_call>...</tool_call> XML-style, and OpenAI-style {"tool_calls": [...]} variants), orMulti-turn conversations extend the same format with additional <|user|> / <|assistant|> / <|tool|> blocks.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-3B-Instruct"
ADAPTER = "navenduk75/qwen2.5-3b-function-calling-lora"
base_model = AutoModelForCausalLM.from_pretrained(BASE_MODEL, torch_dtype=torch.float32)
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
model = PeftModel.from_pretrained(base_model, ADAPTER).merge_and_unload()
prompt = """<|system|>
You are a function-calling model. If the user's request matches one of the available tools, respond ONLY with a JSON object describing the tool to call and its arguments. If no tool applies, or required information is missing, respond in plain natural language instead.
<|tools|>
[{"name": "get_weather", "description": "Get current weather for a location", "parameters": {"type": "object", "properties": {"location": {"type": "string"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}}, "required": ["location"]}}]
<|user|>
What's the weather in Berlin in celsius?
<|assistant|>
"""
inputs = tokenizer(prompt, return_tensors="pt")
output_ids = model.generate(**inputs, max_new_tokens=200, do_sample=False, pad_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(output_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Trained on a synthetic dataset covering: clean single-turn calls, noisy/typo'd phrasing, multiple tool-call output formats, multi-turn conversations with synthetic tool results, and off-topic/ambiguous prompts that should not trigger a tool call. This model was trained with SFT.
Cite TRL as:
@software{vonwerra2020trl,
title = {{TRL: Transformers Reinforcement Learning}},
author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
license = {Apache-2.0},
url = {https://github.com/huggingface/trl},
year = {2020}
}