FunctionGemma 270M

FunctionGemma 270M एक Gemma 3 derivative है जिसे structured tool और function calls के लिए फ़ाइन-ट्यून किया गया है। फ़्री-फ़ॉर्म टेक्स्ट के बजाय, यह एक सख्त <start_function_call>call:NAME{...}<end_function_call> grammar emit करता है जिसे SDK typed FunctionCall वैल्यूज़ में पार्स करता है। डिस्क पर लगभग 283 MB होने के कारण, यह फ़ोन-क्लास हार्डवेयर पर ASR + TTS पाइपलाइन के साथ लोड होने के लिए काफ़ी छोटा है और उस "राउटर" के रूप में काम कर सकता है जो उपयोगकर्ता के यूटरेंस को टूल इन्वोकेशन में बदलता है।

फंक्शन-कॉलिंग, ऑन-डिवाइस

FunctionGemma उन सभी जगहों पर वॉयस एजेंट में फ़िट होता है जहाँ आप अन्यथा टूल राउटिंग के लिए एक hosted LLM कॉल करते। Grammar निर्माण द्वारा ही सख्त है, इसलिए आपको सीधे पार्स किए गए FunctionCall ऑब्जेक्ट्स वापस मिलते हैं — कोई JSON रिपेयर नहीं, कोई schema-mode प्रॉम्प्टिंग नहीं।

प्लेटफ़ॉर्म

प्लेटफ़ॉर्मफ़ॉर्मेटआकारHuggingFace
Apple (macOS / iOS)CoreML~283 MBaufklarer/FunctionGemma-270M-CoreML
Android (और Speech Core के माध्यम से Linux / Windows)LiteRT-LM~283 MBsoniqo/FunctionGemma-270M-LiteRT-LM

Grammar

मॉडल को दो sentinel tokens में लिपटे एक single call (या calls के अनुक्रम) को emit करने के लिए ट्रेन्ड किया गया है:

<start_function_call>call:set_timer{"minutes": 5, "label": "tea"}<end_function_call>

SDK प्रत्येक कॉल को typed FunctionCall(name:, arguments:) वैल्यू में पार्स करता है। Arguments को JSON के रूप में डिकोड किया जाता है ताकि आप उन्हें सीधे एक Swift Codable या Kotlin @Serializable data class पर मैप कर सकें।

Swift (Apple, CoreML)

Apple प्लेटफ़ॉर्म पर FunctionGemma को speech-swift के माध्यम से FunctionGemma क्लास के रूप में एक्सपोज़ किया जाता है। यह पहली बार उपयोग पर HuggingFace से CoreML मॉडल लोड करता है और Neural Engine पर चलता है।

import FunctionGemma

let model = try await FunctionGemma.fromPretrained()

let tools = """
- set_timer(minutes: Int, label: String)
- get_weather(city: String)
"""

let calls = try model.callFunctions(
    tools: tools,
    userMessage: "Set a 5 minute tea timer"
)

for call in calls {
    print(call.name)       // "set_timer"
    print(call.arguments)  // ["minutes": 5, "label": "tea"]
}

Kotlin (Android, LiteRT-LM)

Android पर मॉडल को speech-android के माध्यम से audio.soniqo.speech.llm.FunctionGemma के रूप में एक्सपोज़ किया जाता है। यह एक bring-your-own-runtime अडैप्टर है: आप एक LiteRtLmRuntime इंस्टेंस प्रदान करते हैं (SDK डिफ़ॉल्ट के साथ आता है), और FunctionGemma प्रॉम्प्ट टेम्पलेट और grammar पार्सिंग को संभालता है।

import audio.soniqo.speech.llm.FunctionGemma
import audio.soniqo.speech.llm.LiteRtLmRuntime

val runtime = LiteRtLmRuntime.fromPretrained(context)
val model = FunctionGemma(runtime)

val tools = """
- set_timer(minutes: Int, label: String)
- get_weather(city: String)
""".trimIndent()

val calls = model.callFunctions(
    tools = tools,
    userMessage = "Set a 5 minute tea timer",
)

for (call in calls) {
    println(call.name)       // "set_timer"
    println(call.arguments)  // {"minutes": 5, "label": "tea"}
}

आगे पढ़ें