Downloads · 30 days
100
9% of all-time downloads
renhehuang/functiongemma-270m-it-coffee-robot-mcp
functiongemma-270m-it-coffee-robot-mcp is a text generation model from renhehuang. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gemma.
基於 google/functiongemma-270m-it 微調的咖啡機器人外送任務 Function Calling 模型。(此為企業內部點餐 api 整合測試模型)
Downloads · 30 days
100
9% of all-time downloads
All-time downloads
1.2K
Public
Parameters
268M
1.7 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.1 GB · 65%
From the Hugging Face model README
基於 google/functiongemma-270m-it 微調的咖啡機器人外送任務 Function Calling 模型。(此為企業內部點餐 api 整合測試模型)
此模型專門針對咖啡機器人外送場景進行微調,能夠將自然語言指令轉換為結構化的 Function Call,適用於 MCP (Model Context Protocol) 整合。
send_coffee| 參數 | 類型 | 說明 | 可選值 |
|---|---|---|---|
baseDrink | string | 飲品種類 | americano, latte, oat_latte, milk |
floor | integer | 配送樓層 | 1-11 |
temperature | string | 飲品溫度 | hot, iced |
addons | array | 加購選項 | extra_espresso, paper_cup |
quantity | integer | 數量 | 1-10 |
| 指標 | 基礎模型 | 微調後模型 |
|---|---|---|
| Function Calling 準確率 | 95.95% | 100.00% |
| 提升幅度 | - | +4.05% |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_id = "renhehuang/functiongemma-270m-it-coffee-robot-mcp"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
tools = [
{
"type": "function",
"function": {
"name": "send_coffee",
"description": "送咖啡到指定樓層",
"parameters": {
"type": "object",
"properties": {
"baseDrink": {"type": "string", "enum": ["americano", "latte", "oat_latte", "milk"]},
"floor": {"type": "integer", "minimum": 1, "maximum": 11},
"temperature": {"type": "string", "enum": ["hot", "iced"]},
"addons": {"type": "array", "items": {"type": "string", "enum": ["extra_espresso", "paper_cup"]}},
"quantity": {"type": "integer", "minimum": 1, "maximum": 10},
},
"required": ["baseDrink", "floor", "temperature", "quantity"],
},
},
}
]
messages = [{"role": "user", "content": "幫我送一杯熱美式到五樓"}]
prompt = tokenizer.apply_chat_template(
messages,
tools=tools,
tokenize=False,
add_generation_prompt=True,
)
out = pipe(prompt, max_new_tokens=256, do_sample=False)
print(out[0]["generated_text"][len(prompt):])
輸入: "幫我送一杯熱美式到五樓"
輸出:
<start_function_call>call: send_coffee{baseDrink:<escape>americano<escape>, floor:<escape>5<escape>, temperature:<escape>hot<escape>, quantity:<escape>1<escape>}<end_function_call>
此模型可與 MCP Server 整合,實現自動化咖啡外送流程:
# 解析 Function Call
import re
def parse_function_call(output):
pattern = r"<start_function_call>(.*?)<end_function_call>"
matches = re.findall(pattern, output, re.DOTALL)
# 解析並回傳結構化資料
return matches
@misc{coffee-robot-mcp-2025,
title={Coffee Robot MCP - FunctionGemma Fine-tuned Model},
author={renhehuang},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/renhehuang/functiongemma-270m-it-coffee-robot-mcp}
}
本模型基於 Gemma License 授權。使用前請確認已接受 Google Gemma 的使用條款。