โ˜• Coffee Robot MCP - FunctionGemma 270M

ๅŸบๆ–ผ google/functiongemma-270m-it ๅพฎ่ชฟ็š„ๅ’–ๅ•กๆฉŸๅ™จไบบๅค–้€ไปปๅ‹™ Function Calling ๆจกๅž‹ใ€‚๏ผˆๆญค็‚บไผๆฅญๅ…ง้ƒจ้ปž้ค api ๆ•ดๅˆๆธฌ่ฉฆๆจกๅž‹๏ผ‰

๐Ÿ“‹ ๆจกๅž‹ๆ่ฟฐ

ๆญคๆจกๅž‹ๅฐˆ้–€้‡ๅฐๅ’–ๅ•กๆฉŸๅ™จไบบๅค–้€ๅ ดๆ™ฏ้€ฒ่กŒๅพฎ่ชฟ๏ผŒ่ƒฝๅค ๅฐ‡่‡ช็„ถ่ชž่จ€ๆŒ‡ไปค่ฝ‰ๆ›็‚บ็ตๆง‹ๅŒ–็š„ Function Call๏ผŒ้ฉ็”จๆ–ผ MCP (Model Context Protocol) ๆ•ดๅˆใ€‚

ไธป่ฆ็‰น้ปž

  • ๐ŸŽฏ ๅฐˆๆณจๆ–ผๅ’–ๅ•กๅค–้€ไปปๅ‹™็š„ Function Calling
  • ๐Ÿ‡น๐Ÿ‡ผ ๆ”ฏๆด็น้ซ”ไธญๆ–‡่‡ช็„ถ่ชž่จ€่ผธๅ…ฅ
  • โšก ่ผ•้‡ๅŒ–ๆจกๅž‹๏ผˆ270M ๅƒๆ•ธ๏ผ‰๏ผŒ้ฉๅˆ้‚Š็ทฃ้ƒจ็ฝฒ
  • ๐Ÿ”ง ็›ธๅฎน MCP ๅ”่ญฐๆ ผๅผ

๐Ÿ› ๏ธ ๆ”ฏๆดๅŠŸ่ƒฝ

Function: 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%

่จ“็ทด้…็ฝฎ

  • ่จ“็ทด่ผชๆ•ธ: 3
  • ๅญธ็ฟ’็އ: 1e-05
  • ๆœ‰ๆ•ˆๆ‰นๆฌกๅคงๅฐ: 16
  • ่จ“็ทดๆจฃๆœฌๆ•ธ: 625
  • ้ฉ—่ญ‰ๆจฃๆœฌๆ•ธ: 74

๐Ÿ’ป ไฝฟ็”จๆ–นๅผ

ๅŸบๆœฌไฝฟ็”จ

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 ๆ•ดๅˆ

ๆญคๆจกๅž‹ๅฏ่ˆ‡ 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

โš ๏ธ ้™ๅˆถ่ˆ‡ๆณจๆ„ไบ‹้ …

  1. ้ ˜ๅŸŸ้™ๅˆถ: ๆญคๆจกๅž‹ๅฐˆ็‚บๅ’–ๅ•กๅค–้€ๅ ดๆ™ฏ่จญ่จˆ๏ผŒไธ้ฉ็”จๆ–ผๅ…ถไป– Function Calling ไปปๅ‹™
  2. ่ชž่จ€ๆ”ฏๆด: ไธป่ฆๆ”ฏๆด็น้ซ”ไธญๆ–‡๏ผŒๅ…ถไป–่ชž่จ€ๆ•ˆๆžœๅฏ่ƒฝไธไฝณ
  3. ๆจ“ๅฑค็ฏ„ๅœ: ๅƒ…ๆ”ฏๆด 1-11 ๆจ“
  4. ้ฃฒๅ“็จฎ้กž: ๅƒ…ๆ”ฏๆด 4 ็จฎ้ฃฒๅ“้กžๅž‹

๐Ÿ“ ๅผ•็”จ

@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 ็š„ไฝฟ็”จๆขๆฌพใ€‚

๐Ÿ™ ่‡ด่ฌ

  • Google - ๆไพ› FunctionGemma ๅŸบ็คŽๆจกๅž‹
  • Hugging Face - ๆไพ›ๆจกๅž‹่จ—็ฎก่ˆ‡่จ“็ทดๅทฅๅ…ท
Downloads last month
115
Safetensors
Model size
0.3B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for renhehuang/functiongemma-270m-it-coffee-robot-mcp

Quantized
(70)
this model

Evaluation results