LoRA: Low-Rank Adaptation of Large Language Models
Paper
• 2106.09685 • Published
• 59
Fine-tuned FunctionGemma 270M LoRA adapter specialized for general tool/function calling.
| Link | |
|---|---|
| Source code | tech-sumit/tool-agent |
| Blog post | sumitagrawal.dev/blog/finetuning-functiongemma-270m-tool-calling |
| Base model | unsloth/functiongemma-270m-it |
Evaluated using lm-evaluation-harness on 100 held-out general function-calling examples. End-to-end through the tool agent pipeline: 14% → 57% tool selection accuracy on a 7-query evaluation.
unsloth/functiongemma-270m-it (Gemma 3 270M)| Source | Examples | Purpose |
|---|---|---|
| Salesforce/xlam-function-calling-60k | ~10,000 | General function calling |
| MadeAgents/xlam-irrelevance-7.5k | ~3,000 | Negative examples / refusal |
| Total | ~13,000 |
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("unsloth/functiongemma-270m-it", torch_dtype="auto")
model = PeftModel.from_pretrained(base, "sumitagrawal/functiongemma-270m-tool-agent")
model = model.merge_and_unload()
tokenizer = AutoTokenizer.from_pretrained("sumitagrawal/functiongemma-270m-tool-agent")
prompt = """<start_of_turn>user
You are a model that can do function calling with the following functions
{"name": "get_weather", "description": "Get current weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
{"name": "send_email", "description": "Send an email", "parameters": {"type": "object", "properties": {"to": {"type": "string"}, "subject": {"type": "string"}, "body": {"type": "string"}}, "required": ["to", "subject", "body"]}}
What's the weather in Tokyo?<end_of_turn>
<start_of_turn>model
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, temperature=0.1, do_sample=True)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# <start_function_call>call:get_weather{city:<escape>Tokyo<escape>}<end_function_call>
git clone https://github.com/tech-sumit/tool-agent.git
cd tool-agent
pip install -e .
TOOL_AGENT_BACKEND=transformers \
TOOL_AGENT_MODEL=./models/finetuned \
python -m agent.server
# Server starts on http://localhost:8888 with REST, WebSocket, MCP, and A2A
Export to GGUF first, then:
ollama create tool-agent -f Modelfile
ollama run tool-agent
The model uses FunctionGemma's native control-token format:
<start_function_call>call:function_name{param1:<escape>value1<escape>,param2:<escape>value2<escape>}<end_function_call>
Apache 2.0 (same as the base model).
Base model
google/functiongemma-270m-it