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

문법

모델은 두 개의 센티넬 토큰으로 감싼 단일 호출(또는 호출 시퀀스)을 출력하도록 학습됩니다:

<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로 노출됩니다. 이는 BYOR(Bring-Your-Own-Runtime) 어댑터입니다: 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"}
}

추가 자료