Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -21,8 +21,16 @@ pipeline_tag: text-generation
|
|
| 21 |
Fine-tuned [FunctionGemma 270M](https://huggingface.co/unsloth/functiongemma-270m-it) LoRA adapter
|
| 22 |
specialized for **general tool/function calling**.
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
## Benchmark Results
|
| 25 |
|
|
|
|
|
|
|
| 26 |
Evaluated using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) on 100 held-out general function-calling examples:
|
| 27 |
|
| 28 |
| Metric | Base | Fine-tuned | Delta |
|
|
@@ -32,20 +40,23 @@ Evaluated using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluat
|
|
| 32 |
| Negative Rejection | 100.0% | 100.0% | +0.0% |
|
| 33 |
| Param Accuracy | 49.0% | 68.9% | **+19.9%** |
|
| 34 |
|
|
|
|
|
|
|
| 35 |
## Training
|
| 36 |
|
| 37 |
-
- **Base model**: `unsloth/functiongemma-270m-it`
|
| 38 |
-
- **Method**: LoRA (r=16, alpha=32) via PEFT + TRL SFTTrainer
|
| 39 |
- **Dataset**: 13,000 general function-calling examples
|
| 40 |
- **Epochs**: 3
|
| 41 |
-
- **
|
|
|
|
| 42 |
|
| 43 |
### Data composition
|
| 44 |
|
| 45 |
| Source | Examples | Purpose |
|
| 46 |
|--------|----------|---------|
|
| 47 |
-
| xlam-function-calling-60k | ~10,000 | General function calling |
|
| 48 |
-
| xlam-irrelevance-7.5k | ~3,000 | Negative examples / refusal |
|
| 49 |
| **Total** | **~13,000** | |
|
| 50 |
|
| 51 |
## Usage
|
|
@@ -58,22 +69,36 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 58 |
|
| 59 |
base = AutoModelForCausalLM.from_pretrained("unsloth/functiongemma-270m-it", torch_dtype="auto")
|
| 60 |
model = PeftModel.from_pretrained(base, "sumitagrawal/functiongemma-270m-tool-agent")
|
|
|
|
| 61 |
tokenizer = AutoTokenizer.from_pretrained("sumitagrawal/functiongemma-270m-tool-agent")
|
| 62 |
|
| 63 |
-
prompt = """<start_of_turn>
|
| 64 |
-
You are a
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
<end_of_turn>
|
| 71 |
<start_of_turn>model
|
| 72 |
"""
|
| 73 |
|
| 74 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 75 |
-
out = model.generate(**inputs, max_new_tokens=128, temperature=0.1)
|
| 76 |
-
print(tokenizer.decode(out[0], skip_special_tokens=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
```
|
| 78 |
|
| 79 |
### With Ollama (GGUF)
|
|
@@ -90,7 +115,7 @@ ollama run tool-agent
|
|
| 90 |
The model uses FunctionGemma's native control-token format:
|
| 91 |
|
| 92 |
```
|
| 93 |
-
<start_function_call>call:function_name{param1:<escape>value1<escape>param2:<escape>value2<escape>}<end_function_call>
|
| 94 |
```
|
| 95 |
|
| 96 |
## License
|
|
|
|
| 21 |
Fine-tuned [FunctionGemma 270M](https://huggingface.co/unsloth/functiongemma-270m-it) LoRA adapter
|
| 22 |
specialized for **general tool/function calling**.
|
| 23 |
|
| 24 |
+
| | Link |
|
| 25 |
+
|---|---|
|
| 26 |
+
| **Source code** | [tech-sumit/tool-agent](https://github.com/tech-sumit/tool-agent) |
|
| 27 |
+
| **Blog post** | [sumitagrawal.dev/blog/finetuning-functiongemma-270m-tool-calling](https://sumitagrawal.dev/blog/finetuning-functiongemma-270m-tool-calling/) |
|
| 28 |
+
| **Base model** | [unsloth/functiongemma-270m-it](https://huggingface.co/unsloth/functiongemma-270m-it) |
|
| 29 |
+
|
| 30 |
## Benchmark Results
|
| 31 |
|
| 32 |
+

|
| 33 |
+
|
| 34 |
Evaluated using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) on 100 held-out general function-calling examples:
|
| 35 |
|
| 36 |
| Metric | Base | Fine-tuned | Delta |
|
|
|
|
| 40 |
| Negative Rejection | 100.0% | 100.0% | +0.0% |
|
| 41 |
| Param Accuracy | 49.0% | 68.9% | **+19.9%** |
|
| 42 |
|
| 43 |
+
End-to-end through the [tool agent](https://github.com/tech-sumit/tool-agent) pipeline: **14% → 57%** tool selection accuracy on a 7-query evaluation.
|
| 44 |
+
|
| 45 |
## Training
|
| 46 |
|
| 47 |
+
- **Base model**: [`unsloth/functiongemma-270m-it`](https://huggingface.co/unsloth/functiongemma-270m-it) (Gemma 3 270M)
|
| 48 |
+
- **Method**: [LoRA](https://arxiv.org/abs/2106.09685) (r=16, alpha=32) via [PEFT](https://huggingface.co/docs/peft) + [TRL](https://huggingface.co/docs/trl) SFTTrainer
|
| 49 |
- **Dataset**: 13,000 general function-calling examples
|
| 50 |
- **Epochs**: 3
|
| 51 |
+
- **Training time**: 25 minutes
|
| 52 |
+
- **Hardware**: NVIDIA H100 SXM 80GB via [vast.ai](https://vast.ai)
|
| 53 |
|
| 54 |
### Data composition
|
| 55 |
|
| 56 |
| Source | Examples | Purpose |
|
| 57 |
|--------|----------|---------|
|
| 58 |
+
| [Salesforce/xlam-function-calling-60k](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k) | ~10,000 | General function calling |
|
| 59 |
+
| [MadeAgents/xlam-irrelevance-7.5k](https://huggingface.co/datasets/MadeAgents/xlam-irrelevance-7.5k) | ~3,000 | Negative examples / refusal |
|
| 60 |
| **Total** | **~13,000** | |
|
| 61 |
|
| 62 |
## Usage
|
|
|
|
| 69 |
|
| 70 |
base = AutoModelForCausalLM.from_pretrained("unsloth/functiongemma-270m-it", torch_dtype="auto")
|
| 71 |
model = PeftModel.from_pretrained(base, "sumitagrawal/functiongemma-270m-tool-agent")
|
| 72 |
+
model = model.merge_and_unload()
|
| 73 |
tokenizer = AutoTokenizer.from_pretrained("sumitagrawal/functiongemma-270m-tool-agent")
|
| 74 |
|
| 75 |
+
prompt = """<start_of_turn>user
|
| 76 |
+
You are a model that can do function calling with the following functions
|
| 77 |
+
|
| 78 |
+
{"name": "get_weather", "description": "Get current weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
|
| 79 |
+
{"name": "send_email", "description": "Send an email", "parameters": {"type": "object", "properties": {"to": {"type": "string"}, "subject": {"type": "string"}, "body": {"type": "string"}}, "required": ["to", "subject", "body"]}}
|
| 80 |
+
|
| 81 |
+
What's the weather in Tokyo?<end_of_turn>
|
|
|
|
| 82 |
<start_of_turn>model
|
| 83 |
"""
|
| 84 |
|
| 85 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 86 |
+
out = model.generate(**inputs, max_new_tokens=128, temperature=0.1, do_sample=True)
|
| 87 |
+
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 88 |
+
# <start_function_call>call:get_weather{city:<escape>Tokyo<escape>}<end_function_call>
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### With the Tool Agent Server
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
git clone https://github.com/tech-sumit/tool-agent.git
|
| 95 |
+
cd tool-agent
|
| 96 |
+
pip install -e .
|
| 97 |
+
|
| 98 |
+
TOOL_AGENT_BACKEND=transformers \
|
| 99 |
+
TOOL_AGENT_MODEL=./models/finetuned \
|
| 100 |
+
python -m agent.server
|
| 101 |
+
# Server starts on http://localhost:8888 with REST, WebSocket, MCP, and A2A
|
| 102 |
```
|
| 103 |
|
| 104 |
### With Ollama (GGUF)
|
|
|
|
| 115 |
The model uses FunctionGemma's native control-token format:
|
| 116 |
|
| 117 |
```
|
| 118 |
+
<start_function_call>call:function_name{param1:<escape>value1<escape>,param2:<escape>value2<escape>}<end_function_call>
|
| 119 |
```
|
| 120 |
|
| 121 |
## License
|