Views
No views yet
| Link | |
|---|---|
| Source code | tech-sumit/tool-agent |
| Blog post | sumitagrawal.dev/blog/finetuning-functiongemma-270m-tool-calling |
| Base model | unsloth/functiongemma-270m-it |

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 |
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base = AutoModelForCausalLM.from_pretrained("unsloth/functiongemma-270m-it", torch_dtype="auto")
5model = PeftModel.from_pretrained(base, "sumitagrawal/functiongemma-270m-tool-agent")
6model = model.merge_and_unload()
7tokenizer = AutoTokenizer.from_pretrained("sumitagrawal/functiongemma-270m-tool-agent")
8
9prompt = """<start_of_turn>user
10You are a model that can do function calling with the following functions
11
12{"name": "get_weather", "description": "Get current weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
13{"name": "send_email", "description": "Send an email", "parameters": {"type": "object", "properties": {"to": {"type": "string"}, "subject": {"type": "string"}, "body": {"type": "string"}}, "required": ["to", "subject", "body"]}}
14
15What's the weather in Tokyo?<end_of_turn>
16<start_of_turn>model
17"""
18
19inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20out = model.generate(**inputs, max_new_tokens=128, temperature=0.1, do_sample=True)
21print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
22# <start_function_call>call:get_weather{city:<escape>Tokyo<escape>}<end_function_call>1git clone https://github.com/tech-sumit/tool-agent.git
2cd tool-agent
3pip install -e .
4
5TOOL_AGENT_BACKEND=transformers \
6TOOL_AGENT_MODEL=./models/finetuned \
7python -m agent.server
8# Server starts on http://localhost:8888 with REST, WebSocket, MCP, and A2A1ollama create tool-agent -f Modelfile
2ollama run tool-agent<start_function_call>call:function_name{param1:<escape>value1<escape>,param2:<escape>value2<escape>}<end_function_call>