Text Generation
Transformers
TensorBoard
Safetensors
English
gemma3_text
function-calling
multi-agent
router
gemma
fine-tuned
customer-support
conversational
text-generation-inference
Instructions to use bhaiyasingh45/functiongemma-multiagent-router with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bhaiyasingh45/functiongemma-multiagent-router with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bhaiyasingh45/functiongemma-multiagent-router") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bhaiyasingh45/functiongemma-multiagent-router") model = AutoModelForCausalLM.from_pretrained("bhaiyasingh45/functiongemma-multiagent-router") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bhaiyasingh45/functiongemma-multiagent-router with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bhaiyasingh45/functiongemma-multiagent-router" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bhaiyasingh45/functiongemma-multiagent-router", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bhaiyasingh45/functiongemma-multiagent-router
- SGLang
How to use bhaiyasingh45/functiongemma-multiagent-router with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "bhaiyasingh45/functiongemma-multiagent-router" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bhaiyasingh45/functiongemma-multiagent-router", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "bhaiyasingh45/functiongemma-multiagent-router" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bhaiyasingh45/functiongemma-multiagent-router", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bhaiyasingh45/functiongemma-multiagent-router with Docker Model Runner:
docker model run hf.co/bhaiyasingh45/functiongemma-multiagent-router
Bhaiya Hari Narayan Singh commited on
Add comprehensive model card with usage examples
Browse files
README.md
CHANGED
|
@@ -1,58 +1,363 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
| 3 |
library_name: transformers
|
| 4 |
-
model_name: functiongemma-multiagent-router
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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| 3 |
+
- en
|
| 4 |
+
license: gemma
|
| 5 |
library_name: transformers
|
|
|
|
| 6 |
tags:
|
| 7 |
+
- function-calling
|
| 8 |
+
- multi-agent
|
| 9 |
+
- router
|
| 10 |
+
- gemma
|
| 11 |
+
- fine-tuned
|
| 12 |
+
- customer-support
|
| 13 |
+
base_model: google/functiongemma-270m-it
|
| 14 |
+
datasets:
|
| 15 |
+
- bhaiyahnsingh45/multiagent-router-finetuning
|
| 16 |
+
metrics:
|
| 17 |
+
- accuracy
|
| 18 |
+
pipeline_tag: text-generation
|
| 19 |
+
widget:
|
| 20 |
+
- text: "My app keeps crashing when I upload large files"
|
| 21 |
+
example_title: "Technical Issue"
|
| 22 |
+
- text: "I need a refund for my subscription"
|
| 23 |
+
example_title: "Billing Request"
|
| 24 |
+
- text: "What integrations do you support?"
|
| 25 |
+
example_title: "Product Info"
|
| 26 |
---
|
| 27 |
|
| 28 |
+
# Multi-Agent Router (Fine-tuned FunctionGemma 270M)
|
| 29 |
+
|
| 30 |
+
<div align="center">
|
| 31 |
+
<img src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png" alt="Hugging Face" width="100"/>
|
| 32 |
+
|
| 33 |
+
**Intelligent routing model for multi-agent customer support systems**
|
| 34 |
+
|
| 35 |
+
[](https://ai.google.dev/gemma/terms)
|
| 36 |
+
[](https://huggingface.co/google/functiongemma-270m-it)
|
| 37 |
+
[](https://huggingface.co/datasets/bhaiyahnsingh45/multiagent-router-finetuning)
|
| 38 |
+
</div>
|
| 39 |
+
|
| 40 |
+
## ๐ Model Description
|
| 41 |
+
|
| 42 |
+
This model is a **fine-tuned version of Google's FunctionGemma 270M** specifically trained for intelligent routing in multi-agent customer support systems. It learns to:
|
| 43 |
+
|
| 44 |
+
1. **Classify user intent** from natural language queries
|
| 45 |
+
2. **Route to the appropriate specialist agent**
|
| 46 |
+
3. **Extract relevant parameters** (priority, urgency, category)
|
| 47 |
+
|
| 48 |
+
### ๐ค Supported Agents
|
| 49 |
+
|
| 50 |
+
The model routes queries to three specialized agents:
|
| 51 |
+
|
| 52 |
+
| Agent | Handles | Parameters |
|
| 53 |
+
|-------|---------|------------|
|
| 54 |
+
| ๐ง **Technical Support** | Crashes, bugs, API errors, authentication issues | `issue_type`, `priority` |
|
| 55 |
+
| ๐ฐ **Billing** | Payments, refunds, subscriptions, invoices | `request_type`, `urgency` |
|
| 56 |
+
| ๐ **Product Info** | Features, integrations, plans, compliance | `query_type`, `category` |
|
| 57 |
+
|
| 58 |
+
## ๐ฏ Training Details
|
| 59 |
+
|
| 60 |
+
### Base Model
|
| 61 |
+
- **Model**: `google/functiongemma-270m-it`
|
| 62 |
+
- **Parameters**: 270 Million
|
| 63 |
+
- **Architecture**: Gemma with function calling capabilities
|
| 64 |
+
|
| 65 |
+
### Fine-tuning Configuration
|
| 66 |
+
- **Training Samples**: 92
|
| 67 |
+
- **Test Samples**: 23
|
| 68 |
+
- **Epochs**: 15
|
| 69 |
+
- **Batch Size**: 4
|
| 70 |
+
- **Learning Rate**: 5e-05
|
| 71 |
+
- **GPU**: NVIDIA T4 (Google Colab Free Tier)
|
| 72 |
+
- **Training Time**: ~5-8 minutes
|
| 73 |
+
|
| 74 |
+
### Dataset
|
| 75 |
+
Fine-tuned on [bhaiyahnsingh45/multiagent-router-finetuning](https://huggingface.co/datasets/bhaiyahnsingh45/multiagent-router-finetuning) containing 85 realistic customer support queries across three categories.
|
| 76 |
+
|
| 77 |
+
## ๐ Performance
|
| 78 |
+
|
| 79 |
+
| Metric | Before Training | After Training | Improvement |
|
| 80 |
+
|--------|----------------|----------------|-------------|
|
| 81 |
+
| **Accuracy** | 4.3% | 60.9% | **+56.5%** |
|
| 82 |
+
| **Correct Predictions** | 1/23 | 14/23 | +13 |
|
| 83 |
+
|
| 84 |
+
### Per-Agent Performance
|
| 85 |
+
- **Technical Support**: High accuracy on crash reports, API errors, authentication issues
|
| 86 |
+
- **Billing**: Excellent routing for refunds, payments, subscription management
|
| 87 |
+
- **Product Info**: Strong performance on feature queries, integrations, compliance questions
|
| 88 |
+
|
| 89 |
+
## ๐ Quick Start
|
| 90 |
+
|
| 91 |
+
### Installation
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
pip install transformers torch
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
### Basic Usage
|
| 98 |
+
|
| 99 |
+
```python
|
| 100 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 101 |
+
import re
|
| 102 |
+
import json
|
| 103 |
+
|
| 104 |
+
# Load model and tokenizer
|
| 105 |
+
model_name = "bhaiyahnsingh45/functiongemma-multiagent-router"
|
| 106 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 107 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 108 |
+
model_name,
|
| 109 |
+
device_map="auto",
|
| 110 |
+
torch_dtype="auto"
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
# Define your agent tools
|
| 114 |
+
from transformers.utils import get_json_schema
|
| 115 |
+
|
| 116 |
+
def technical_support_agent(issue_type: str, priority: str) -> str:
|
| 117 |
+
"""
|
| 118 |
+
Routes technical issues to specialized support team.
|
| 119 |
+
|
| 120 |
+
Args:
|
| 121 |
+
issue_type: Type of technical issue (crash, authentication, performance, api_error, etc.)
|
| 122 |
+
priority: Priority level (low, medium, high)
|
| 123 |
+
"""
|
| 124 |
+
return f"Routing to Technical Support: {issue_type} with {priority} priority"
|
| 125 |
+
|
| 126 |
+
def billing_agent(request_type: str, urgency: str) -> str:
|
| 127 |
+
"""
|
| 128 |
+
Routes billing and payment queries.
|
| 129 |
+
|
| 130 |
+
Args:
|
| 131 |
+
request_type: Type of request (refund, invoice, upgrade, cancellation, etc.)
|
| 132 |
+
urgency: How urgent (low, medium, high)
|
| 133 |
+
"""
|
| 134 |
+
return f"Routing to Billing: {request_type} with {urgency} urgency"
|
| 135 |
+
|
| 136 |
+
def product_info_agent(query_type: str, category: str) -> str:
|
| 137 |
+
"""
|
| 138 |
+
Routes product information queries.
|
| 139 |
+
|
| 140 |
+
Args:
|
| 141 |
+
query_type: Type of query (features, comparison, integrations, limits, etc.)
|
| 142 |
+
category: Category (plans, storage, mobile, security, etc.)
|
| 143 |
+
"""
|
| 144 |
+
return f"Routing to Product Info: {query_type} about {category}"
|
| 145 |
+
|
| 146 |
+
# Get tool schemas
|
| 147 |
+
AGENT_TOOLS = [
|
| 148 |
+
get_json_schema(technical_support_agent),
|
| 149 |
+
get_json_schema(billing_agent),
|
| 150 |
+
get_json_schema(product_info_agent)
|
| 151 |
+
]
|
| 152 |
+
|
| 153 |
+
# System message
|
| 154 |
+
SYSTEM_MSG = "You are an intelligent routing agent that directs customer queries to the appropriate specialized agent."
|
| 155 |
+
|
| 156 |
+
# Function to route queries
|
| 157 |
+
def route_query(user_query: str):
|
| 158 |
+
"""Route a user query to the appropriate agent"""
|
| 159 |
+
|
| 160 |
+
messages = [
|
| 161 |
+
{"role": "developer", "content": SYSTEM_MSG},
|
| 162 |
+
{"role": "user", "content": user_query}
|
| 163 |
+
]
|
| 164 |
+
|
| 165 |
+
# Format prompt
|
| 166 |
+
inputs = tokenizer.apply_chat_template(
|
| 167 |
+
messages,
|
| 168 |
+
tools=AGENT_TOOLS,
|
| 169 |
+
add_generation_prompt=True,
|
| 170 |
+
return_dict=True,
|
| 171 |
+
return_tensors="pt"
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
# Generate
|
| 175 |
+
outputs = model.generate(
|
| 176 |
+
**inputs.to(model.device),
|
| 177 |
+
max_new_tokens=128,
|
| 178 |
+
pad_token_id=tokenizer.eos_token_id
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
# Decode
|
| 182 |
+
result = tokenizer.decode(
|
| 183 |
+
outputs[0][len(inputs["input_ids"][0]):],
|
| 184 |
+
skip_special_tokens=False
|
| 185 |
+
)
|
| 186 |
|
| 187 |
+
return result
|
|
|
|
| 188 |
|
| 189 |
+
# Example usage
|
| 190 |
+
query = "My app crashes when I try to upload large files"
|
| 191 |
+
result = route_query(query)
|
| 192 |
+
print(f"Query: {query}")
|
| 193 |
+
print(f"Routing: {result}")
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
### Expected Output Format
|
| 197 |
+
|
| 198 |
+
```
|
| 199 |
+
<start_function_call>call:technical_support_agent{issue_type:crash,priority:high}<end_function_call>
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
## ๐ก Usage Examples
|
| 203 |
+
|
| 204 |
+
### Example 1: Technical Issue
|
| 205 |
+
```python
|
| 206 |
+
query = "I'm getting a 500 error when calling the API"
|
| 207 |
+
result = route_query(query)
|
| 208 |
+
# Output: technical_support_agent(issue_type="api_error", priority="high")
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
### Example 2: Billing Request
|
| 212 |
+
```python
|
| 213 |
+
query = "I need a refund for my annual subscription"
|
| 214 |
+
result = route_query(query)
|
| 215 |
+
# Output: billing_agent(request_type="refund", urgency="medium")
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
### Example 3: Product Question
|
| 219 |
+
```python
|
| 220 |
+
query = "What integrations do you support for project management?"
|
| 221 |
+
result = route_query(query)
|
| 222 |
+
# Output: product_info_agent(query_type="integrations", category="project_management")
|
| 223 |
+
```
|
| 224 |
+
|
| 225 |
+
## ๐ง Advanced Usage: Parse Function Calls
|
| 226 |
|
| 227 |
```python
|
| 228 |
+
def parse_function_call(output: str) -> dict:
|
| 229 |
+
"""Extract function name and arguments from model output"""
|
| 230 |
+
|
| 231 |
+
pattern = r'<start_function_call>call:(\w+)\{([^}]+)\}<end_function_call>'
|
| 232 |
+
match = re.search(pattern, output)
|
| 233 |
+
|
| 234 |
+
if match:
|
| 235 |
+
func_name = match.group(1)
|
| 236 |
+
params_str = match.group(2)
|
| 237 |
+
|
| 238 |
+
# Parse parameters
|
| 239 |
+
params = {}
|
| 240 |
+
param_pattern = r'(\w+):(?:<escape>(.*?)<escape>|([^,{}]+))'
|
| 241 |
+
for p_match in re.finditer(param_pattern, params_str):
|
| 242 |
+
key = p_match.group(1)
|
| 243 |
+
val = p_match.group(2) or p_match.group(3).strip()
|
| 244 |
+
params[key] = val
|
| 245 |
+
|
| 246 |
+
return {
|
| 247 |
+
"agent": func_name,
|
| 248 |
+
"parameters": params
|
| 249 |
+
}
|
| 250 |
|
| 251 |
+
return {"agent": "unknown", "parameters": {}}
|
| 252 |
+
|
| 253 |
+
# Use it
|
| 254 |
+
query = "I was charged twice this month"
|
| 255 |
+
result = route_query(query)
|
| 256 |
+
parsed = parse_function_call(result)
|
| 257 |
+
print(parsed)
|
| 258 |
+
# Output: {'agent': 'billing_agent', 'parameters': {'request_type': 'dispute', 'urgency': 'high'}}
|
| 259 |
```
|
| 260 |
|
| 261 |
+
## ๐๏ธ Integration Example
|
| 262 |
+
|
| 263 |
+
```python
|
| 264 |
+
class MultiAgentRouter:
|
| 265 |
+
def __init__(self, model_name: str):
|
| 266 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 267 |
+
self.model = AutoModelForCausalLM.from_pretrained(
|
| 268 |
+
model_name,
|
| 269 |
+
device_map="auto",
|
| 270 |
+
torch_dtype="auto"
|
| 271 |
+
)
|
| 272 |
+
self.system_msg = "You are an intelligent routing agent..."
|
| 273 |
+
|
| 274 |
+
def route(self, query: str) -> dict:
|
| 275 |
+
"""Route query and return agent + parameters"""
|
| 276 |
+
messages = [
|
| 277 |
+
{"role": "developer", "content": self.system_msg},
|
| 278 |
+
{"role": "user", "content": query}
|
| 279 |
+
]
|
| 280 |
+
|
| 281 |
+
inputs = self.tokenizer.apply_chat_template(
|
| 282 |
+
messages,
|
| 283 |
+
tools=AGENT_TOOLS,
|
| 284 |
+
add_generation_prompt=True,
|
| 285 |
+
return_dict=True,
|
| 286 |
+
return_tensors="pt"
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
outputs = self.model.generate(
|
| 290 |
+
**inputs.to(self.model.device),
|
| 291 |
+
max_new_tokens=128,
|
| 292 |
+
pad_token_id=self.tokenizer.eos_token_id
|
| 293 |
+
)
|
| 294 |
+
|
| 295 |
+
result = self.tokenizer.decode(
|
| 296 |
+
outputs[0][len(inputs["input_ids"][0]):],
|
| 297 |
+
skip_special_tokens=False
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
return parse_function_call(result)
|
| 301 |
+
|
| 302 |
+
# Usage
|
| 303 |
+
router = MultiAgentRouter("bhaiyahnsingh45/functiongemma-multiagent-router")
|
| 304 |
+
routing = router.route("My payment failed but I don't know why")
|
| 305 |
+
print(f"Route to: {routing['agent']}")
|
| 306 |
+
print(f"Parameters: {routing['parameters']}")
|
| 307 |
+
```
|
| 308 |
|
| 309 |
+
## ๐ Evaluation
|
| 310 |
|
| 311 |
+
The model was evaluated on a held-out test set of 23 queries:
|
| 312 |
|
| 313 |
+
- **Routing Accuracy**: 60.9%
|
| 314 |
+
- **False Positive Rate**: 39.1%
|
| 315 |
+
- **Average Inference Time**: ~50ms on T4 GPU
|
| 316 |
|
| 317 |
+
## โ ๏ธ Limitations
|
| 318 |
|
| 319 |
+
1. **Language**: Currently supports English only
|
| 320 |
+
2. **Domain**: Optimized for customer support; may need fine-tuning for other domains
|
| 321 |
+
3. **Agents**: Limited to 3 agent types (can be extended with additional training)
|
| 322 |
+
4. **Context**: Works best with single-turn queries; multi-turn conversations may need context handling
|
| 323 |
+
5. **Edge Cases**: Ambiguous queries may require fallback logic
|
| 324 |
|
| 325 |
+
## ๐ฎ Future Improvements
|
| 326 |
|
| 327 |
+
- [ ] Add support for more languages
|
| 328 |
+
- [ ] Expand to 5+ agent types (sales, feedback, onboarding)
|
| 329 |
+
- [ ] Handle multi-turn conversations
|
| 330 |
+
- [ ] Add confidence scores for routing decisions
|
| 331 |
+
- [ ] Support for compound queries requiring multiple agents
|
| 332 |
|
| 333 |
+
## ๐ Citation
|
| 334 |
|
|
|
|
|
|
|
| 335 |
```bibtex
|
| 336 |
+
@misc{functiongemma_multiagent_router,
|
| 337 |
+
author = {Bhaiya Singh},
|
| 338 |
+
title = {Multi-Agent Router: Fine-tuned FunctionGemma for Customer Support},
|
| 339 |
+
year = {2025},
|
| 340 |
+
publisher = {Hugging Face},
|
| 341 |
+
howpublished = {\url{https://huggingface.co/bhaiyahnsingh45/functiongemma-multiagent-router}}
|
|
|
|
| 342 |
}
|
| 343 |
+
```
|
| 344 |
+
|
| 345 |
+
## ๐ License
|
| 346 |
+
|
| 347 |
+
This model inherits the [Gemma License](https://ai.google.dev/gemma/terms) from the base model.
|
| 348 |
+
|
| 349 |
+
## ๐ Acknowledgments
|
| 350 |
+
|
| 351 |
+
- Base model: [google/functiongemma-270m-it](https://huggingface.co/google/functiongemma-270m-it)
|
| 352 |
+
- Training framework: [Hugging Face TRL](https://github.com/huggingface/trl)
|
| 353 |
+
- Dataset: [bhaiyahnsingh45/multiagent-router-finetuning](https://huggingface.co/datasets/bhaiyahnsingh45/multiagent-router-finetuning)
|
| 354 |
+
|
| 355 |
+
## ๐ง Contact
|
| 356 |
+
|
| 357 |
+
For questions, issues, or collaboration opportunities:
|
| 358 |
+
- Open an issue on the [model repository](https://huggingface.co/bhaiyahnsingh45/functiongemma-multiagent-router)
|
| 359 |
+
- Dataset issues: [dataset repository](https://huggingface.co/datasets/bhaiyahnsingh45/multiagent-router-finetuning)
|
| 360 |
+
|
| 361 |
+
---
|
| 362 |
+
|
| 363 |
+
**Built with โค๏ธ using FunctionGemma and Hugging Face Transformers**
|