FunctionGemma 270M

FunctionGemma 270Mは、構造化されたツールおよび関数呼び出しのためにファインチューニングされたGemma 3派生モデルです。自由形式のテキストの代わりに、SDKが型付きFunctionCall値にパースする厳密な<start_function_call>call:NAME{...}<end_function_call>文法を出力します。ディスク上で約283 MBと小さく、スマートフォンクラスのハードウェア上でASR + TTSパイプラインと並行してロードでき、ユーザーの発話をツール呼び出しに変換する「ルーター」として機能します。

オンデバイスでの関数呼び出し

FunctionGemmaは、ツールルーティングのためにホスト型LLMを呼び出す代わりに音声エージェントに組み込まれます。文法は構造的に厳密であるため、パース済みのFunctionCallオブジェクトが直接返されます。JSON修復もスキーマモードプロンプトも不要です。

プラットフォーム

プラットフォームフォーマットサイズHuggingFace
Apple (macOS / iOS)CoreML約283 MBaufklarer/FunctionGemma-270M-CoreML
Android (および Speech Core 経由の Linux / Windows)LiteRT-LM約283 MBsoniqo/FunctionGemma-270M-LiteRT-LM

文法

モデルは、2つのセンチネルトークンで囲まれた単一の呼び出し(または一連の呼び出し)を出力するように学習されています。

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

SDKは各呼び出しを型付きのFunctionCall(name:, arguments:)値にパースします。引数はJSONとしてデコードされるため、SwiftのCodableやKotlinの@Serializableデータクラスにそのままマッピングできます。

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として公開されています。これは独自ランタイム持ち込み式のアダプターです。LiteRtLmRuntimeのインスタンスを提供すれば(SDKにはデフォルトのものが同梱されています)、FunctionGemmaがプロンプトテンプレートと文法のパースを処理します。

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

関連資料