essobi/functiongemma-mobile-actions-v5-gguf
013
FunctionGemma Mobile Actions v5 - GGUF
GGUF quantized versions of FunctionGemma Mobile Actions v5 for use with llama.cpp, Ollama, LM Studio, and other GGUF-compatible tools.
Available Quantizations
Supported Functions
Usage with llama.cpp
Download
# Using huggingface-cli
huggingface-cli download essobi/functiongemma-mobile-actions-v5-gguf functiongemma-v5-Q8_0.gguf --local-dir .
# Or with wget
wget https://huggingface.co/essobi/functiongemma-mobile-actions-v5-gguf/resolve/main/functiongemma-v5-Q8_0.ggufCLI Inference
# Simple inference
./llama-cli -m functiongemma-v5-Q8_0.gguf -p "<start_of_turn>user
Set an alarm for 7am<end_of_turn>
<start_of_turn>model
" -n 100 --temp 0.1
# With full prompt format (recommended)
./llama-cli -m functiongemma-v5-Q8_0.gguf \
--prompt "<start_of_turn>developer
Current date and time given in YYYY-MM-DDTHH:MM:SS format: 2025-01-26T10:30:00
Day of week is Sunday
You are a model that can do function calling with the following functions<start_function_declaration>declaration:set_alarm{description:<escape>Sets an alarm for a specific time.<escape>,parameters:{properties:{datetime:{description:<escape>The time for the alarm.<escape>,type:<escape>STRING<escape>}},required:[<escape>datetime<escape>],type:<escape>OBJECT<escape>}}<end_function_declaration><end_of_turn>
<start_of_turn>user
Wake me up at 7am tomorrow<end_of_turn>
<start_of_turn>model
" \
-n 100 --temp 0.1llama.cpp Server
# Start the server
./llama-server -m functiongemma-v5-Q8_0.gguf --port 8080
# Query via curl
curl http://localhost:8080/completion \
-H "Content-Type: application/json" \
-d '{
"prompt": "<start_of_turn>user\nRemind me to buy milk<end_of_turn>\n<start_of_turn>model\n",
"n_predict": 100,
"temperature": 0.1
}'Python with llama-cpp-python
pip install llama-cpp-pythonfrom llama_cpp import Llama
from datetime import datetime
# Load model
llm = Llama(
model_path="functiongemma-v5-Q8_0.gguf",
n_ctx=4096,
n_gpu_layers=-1, # Use GPU if available
)
def build_prompt(user_input: str, tools: list) -> str:
"""Build prompt in FunctionGemma format."""
now = datetime.now()
dt_str = now.strftime("%Y-%m-%dT%H:%M:%S")
day = now.strftime("%A")
# Build function declarations
func_decls = ""
for tool in tools:
func = tool["function"]
props = func["parameters"].get("properties", {})
required = func["parameters"].get("required", [])
props_str = ""
for pname, pinfo in props.items():
desc = pinfo.get("description", "")
ptype = pinfo.get("type", "STRING")
props_str += f"{pname}:{{description:<escape>{desc}<escape>,type:<escape>{ptype}<escape>}},"
props_str = props_str.rstrip(",")
req_str = ",".join([f"<escape>{r}<escape>" for r in required])
func_decls += f"<start_function_declaration>declaration:{func['name']}{{description:<escape>{func['description']}<escape>,parameters:{{properties:{{{props_str}}},required:[{req_str}],type:<escape>OBJECT<escape>}}}}<end_function_declaration>"
return f"""<start_of_turn>developer
Current date and time given in YYYY-MM-DDTHH:MM:SS format: {dt_str}
Day of week is {day}
You are a model that can do function calling with the following functions{func_decls}<end_of_turn>
<start_of_turn>user
{user_input}<end_of_turn>
<start_of_turn>model
"""
# Define tools
tools = [
{
"function": {
"name": "set_alarm",
"description": "Sets an alarm for a specific time.",
"parameters": {
"type": "OBJECT",
"properties": {
"datetime": {"type": "STRING", "description": "The time for the alarm."},
},
"required": ["datetime"]
}
}
},
{
"function": {
"name": "create_reminder",
"description": "Creates a reminder with text and optional time.",
"parameters": {
"type": "OBJECT",
"properties": {
"body": {"type": "STRING", "description": "The reminder text."},
},
"required": ["body"]
}
}
},
]
# Generate
prompt = build_prompt("Set an alarm for 7am", tools)
output = llm(prompt, max_tokens=100, temperature=0.1, stop=["<end_of_turn>"])
print(output["choices"][0]["text"])
# Output: <start_function_call>call:set_alarm{datetime:<escape>7am<escape>}<end_function_call>Usage with Ollama
Create Modelfile
# Modelfile
FROM ./functiongemma-v5-Q8_0.gguf
TEMPLATE """<start_of_turn>user
{{ .Prompt }}<end_of_turn>
<start_of_turn>model
"""
PARAMETER temperature 0.1
PARAMETER stop <end_of_turn>
PARAMETER stop <end_function_call>Run with Ollama
# Create the model
ollama create functiongemma -f Modelfile
# Run inference
ollama run functiongemma "Set an alarm for 7am"Usage with LM Studio
- Download
functiongemma-v5-Q8_0.gguf - Open LM Studio and import the model
- Use the chat interface with the prompt format shown above
Output Format
The model outputs function calls in this format:
<start_function_call>call:function_name{param1:<escape>value1<escape>,param2:<escape>value2<escape>}<end_function_call>Parsing Function Calls
import re
def parse_function_call(text: str) -> dict | None:
"""Parse function call from model output."""
match = re.search(
r'<start_function_call>call:(\w+)\{([^}]*)\}<end_function_call>',
text
)
if not match:
return None
func_name = match.group(1)
args_str = match.group(2)
# Parse arguments
args = {}
for param_match in re.finditer(r'(\w+):<escape>([^<]*)<escape>', args_str):
args[param_match.group(1)] = param_match.group(2)
return {"name": func_name, "arguments": args}
# Example
output = "<start_function_call>call:set_alarm{datetime:<escape>7am<escape>}<end_function_call>"
parsed = parse_function_call(output)
print(parsed)
# {'name': 'set_alarm', 'arguments': {'datetime': '7am'}}Performance
Limitations
- Optimized for English only
- Best for single-turn function calling
- May struggle with highly ambiguous requests
License
This model is released under the Gemma License.
Related Models
- 16-bit version - For vLLM and Transformers
