Salesforce/xlam-function-calling-60k
Viewer • Updated • 60k • 35.5k • 633
How to use debashis/llama-1b-tool-router-grpo with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="debashis/llama-1b-tool-router-grpo")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("debashis/llama-1b-tool-router-grpo")
model = AutoModelForCausalLM.from_pretrained("debashis/llama-1b-tool-router-grpo")
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]:]))How to use debashis/llama-1b-tool-router-grpo with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "debashis/llama-1b-tool-router-grpo"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "debashis/llama-1b-tool-router-grpo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/debashis/llama-1b-tool-router-grpo
How to use debashis/llama-1b-tool-router-grpo with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "debashis/llama-1b-tool-router-grpo" \
--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": "debashis/llama-1b-tool-router-grpo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "debashis/llama-1b-tool-router-grpo" \
--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": "debashis/llama-1b-tool-router-grpo",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use debashis/llama-1b-tool-router-grpo with Docker Model Runner:
docker model run hf.co/debashis/llama-1b-tool-router-grpo
A 1B parameter model trained with pure PyTorch GRPO for fast, accurate tool selection in agentic AI systems.
| Metric | Value |
|---|---|
| Validation Accuracy | 87.94% |
| Parameters | 1B |
| Training | GRPO only (no SFT) |
| Dataset | Salesforce xLAM 60k |
| GPT-4 / Claude API | This Model | |
|---|---|---|
| Latency | 2-5 seconds | 100-500ms |
| Cost/call | $0.01-0.03 | ~$0.0001 |
| Privacy | Cloud | Local |
| Offline | ❌ | ✅ |
100x cheaper. 10x faster. Runs anywhere.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"debashis/llama-1b-tool-router-grpo",
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("debashis/llama-1b-tool-router-grpo")
def call_tool(query: str, tools: list) -> str:
tools_text = ""
for i, tool in enumerate(tools, 1):
tools_text += f"{i}. {tool['name']}\n"
tools_text += f" Description: {tool['description']}\n"
tools_text += f" Parameters: {', '.join(tool['parameters'])}\n"
prompt = f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a function calling assistant. Based on the user's query, call the appropriate function with correct arguments.
Available functions:
{tools_text}
Respond with a JSON object: {{"name": "function_name", "arguments": {{"param1": "value1"}}}}
Only output JSON.<|eot_id|><|start_header_id|>user<|end_header_id|}
{query}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=150, temperature=0.1, do_sample=False)
return tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
tools = [
{"name": "search_flights", "description": "Search for flights",
"parameters": ["origin", "destination", "date"]},
{"name": "book_hotel", "description": "Book a hotel room",
"parameters": ["city", "checkin", "checkout"]},
]
result = call_tool("Find flights from NYC to London on Dec 25th", tools)
# Output: {"name": "search_flights", "arguments": {"origin": "NYC", "destination": "London", "date": "Dec 25th"}}
| Parameter | Value |
|---|---|
| Base model | LLaMA 3.2 1B Instruct |
| Algorithm | GRPO (Pure PyTorch) |
| Epochs | 3 |
| Learning rate | 1e-6 |
| KL coefficient | 0.1 |
| Temperature | 0.7 (train) / 0.1 (inference) |
@misc{llama-tool-router-grpo-2025,
author = {Debashis Ghosh},
title = {LLaMA 1B Tool Router: GRPO-Trained for Agentic Systems},
year = {2026},
publisher = {Hugging Face}
}
Base model
meta-llama/Llama-3.2-1B-Instruct