Automatische vertaling · Engels origineel

FunctionGemma 270M

Function Gemma 270M is een Gemma 3 derivaat gefiniëerd voor gestructureerde tool- en functieaanroepen. In plaats van tekst in vrije vorm, zendt het een strikte <start_function_call>call:NAME{...}<end_function_call> grammatica uit die SDK in getypte FunctionCall waarden verwerkt. Bij ongeveer 283 MB op schijf is het klein genoeg om naast een ASR + TTS pijplijn te gebruiken en dienst te doen als de router die een gebruiker een uitdrukking in een vocation maakt.

Functie-oproep, On-apparaat

FunctionGemma slots in spraakapparaten waar je anders een gehost LLM voor gereedschapsrouting zou noemen. De grammatica is strikt door constructie, dus je krijgt terug ontleed FunctionCall objecten direct

Platforms

PlatformFormaat GrootteHuggingFace
Apple (macOS / iOS)CoreML~283 MBaufklarer/FunctionGemma-270M-CoreML
Android (en Linux / Windows via Speech Core)Litert-LM~283 MBsoniqo/FunctionGemma-270M-LiteRT-LM

Grammatica

Het model is getraind om een enkele oproep (of een reeks oproepen) verpakt in twee verklikker tokens uit te zenden:

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

De SDK verwerkt elke oproep in een getypte FunctionCall(name:, arguments:) waarde. Argumenten worden gedecodeerd als JSON zodat je ze direct kunt in kaart brengen op een Swift Codable of een Kotlin @Serializable data class.

Swift (Apple, CoreML)

Op Apple-platforms FunctionGemma blootgesteld via speech-swift als FunctionGemma klasse. Het laadt het CoreML model van HuggingFace bij eerste gebruik en draait op de 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)

Op Android wordt het model blootgesteld via speech-android als audio.soniqo.speech.llm.FunctionGemma. Het is een bring-your-own-runtime adapter: je geeft een LiteRtLmRuntime instantie (de SDK verscheept een standaard adapter) en FunctionGemma behandelt de prompt sjabloon en grammatica parsing.

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"}
}

Verdere lezing