Views
No views yet
ollama run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-ggufroshangrewal/gemma4-e4b-toolcall-v02-gguf in the model browserNote: This model retains full conversational abilities of Gemma 4. Tool-calling was added as an additional capability — it can still chat, reason, and answer questions normally. It simply also knows when and how to call tools.
| File | Quant | Size | Use Case |
|---|---|---|---|
gemma4-toolcall-v02-Q8_0.gguf | Q8_0 | ~8 GB | Best quality, needs 10GB+ RAM |
apply_chat_template), you need to construct prompts in this native format:<|turn>system ← system turn start
You are a helpful assistant. ← system message
<|tool>declaration:get_weather{...}<tool|> ← tool definition
<turn|> ← system turn end
<|turn>user ← user turn start
What's the weather in Mumbai? ← user message
<turn|> ← user turn end
<|turn>model ← model turn start (model generates from here)<|"|> instead of normal quotes:declaration:function_name{description:<|"|>Some description<|"|>,parameters:{...}}<|tool_call>call:get_weather{city:<|"|>Mumbai<|"|>}<tool_call|>{"name": "get_weather", "arguments": {"city": "Mumbai"}}Tip: If this format looks complex, consider using the full HuggingFace model instead — it has aprocessor.apply_chat_template()that handles all formatting automatically from standard JSON.
1# Download
2huggingface-cli download roshangrewal/gemma4-e4b-toolcall-v02-gguf gemma4-toolcall-v02-Q8_0.gguf --local-dir .
3
4# Run inference
5./llama-cli -m gemma4-toolcall-v02-Q8_0.gguf \
6 -p "<|turn>system\nYou are a helpful assistant.<|tool>declaration:get_weather{description:<|\"|>Get weather for a city<|\"|>,parameters:{properties:{city:{type:<|\"|>STRING<|\"|>}},required:[<|\"|>city<|\"|>],type:<|\"|>OBJECT<|\"|>}}<tool|><turn|>\n<|turn>user\nWhat's the weather in Mumbai?<turn|>\n<|turn>model\n" \
7 -n 1001# Create a Modelfile
2cat > Modelfile << 'EOF'
3FROM ./gemma4-toolcall-v02-Q8_0.gguf
4
5TEMPLATE """<|turn>system
6{{ .System }}<turn|>
7<|turn>user
8{{ .Prompt }}<turn|>
9<|turn>model
10"""
11
12PARAMETER temperature 0
13PARAMETER stop "<turn|>"
14PARAMETER stop "<eos>"
15
16SYSTEM "You are a helpful assistant with access to tools."
17EOF
18
19# Create and run
20ollama create gemma4-toolcall -f Modelfile
21ollama run gemma4-toolcall "What's the weather in Delhi?"1from llama_cpp import Llama
2
3llm = Llama(model_path="gemma4-toolcall-v02-Q8_0.gguf", n_ctx=4096)
4
5# Build prompt in Gemma 4 native format
6# Tool definition with special <|"|> quote tokens
7prompt = '''<|turn>system
8You are a helpful assistant.<|tool>declaration:get_weather{description:<|"|>Get current weather<|"|>,parameters:{properties:{city:{type:<|"|>STRING<|"|>}},required:[<|"|>city<|"|>],type:<|"|>OBJECT<|"|>}}<tool|><turn|>
9<|turn>user
10What's the weather in Mumbai?<turn|>
11<|turn>model
12'''
13
14output = llm(prompt, max_tokens=100, stop=["<turn|>", "<eos>"])
15print(output["choices"][0]["text"])
16# Output: <|tool_call>call:get_weather{city:<|"|>Mumbai<|"|>}<tool_call|>
17# Which means: calling get_weather with city="Mumbai"1import re
2
3response = output["choices"][0]["text"]
4
5# Extract function name and parameters
6match = re.search(r"call:(\w+)\{(.+?)\}", response, re.DOTALL)
7if match:
8 function_name = match.group(1) # "get_weather"
9 params_raw = match.group(2)
10
11 # Parse params: key:<|"|>value<|"|> format
12 params = {}
13 for key, value in re.findall(r'(\w+):<\|"\|>(.*?)<\|"\|>', params_raw):
14 params[key] = value
15 # Also parse numeric params: key:number
16 for key, value in re.findall(r'(\w+):(\d+(?:\.\d+)?)', params_raw):
17 if key not in params:
18 params[key] = float(value) if '.' in value else int(value)
19
20 print(f"Function: {function_name}") # get_weather
21 print(f"Params: {params}") # {"city": "Mumbai"}
22else:
23 # Model chose not to call a tool — responded with text directly
24 print(f"Response: {response}")gemma4-toolcall-v02-Q8_0.gguf| Category | Accuracy |
|---|---|
| Multiple | 95.0% |
| Parallel | 90.0% |
| Simple Python | 88.5% |
| Parallel Multiple | 86.0% |
| Live Simple | 79.8% |
| Non-Live Average | 86.5% |
| Category | Accuracy |
|---|---|
| Simple (clear intent) | 100% |
| Complex params | 100% |
| Many tools (12+) | 93% |
| Ambiguous (similar tools) | 91.5% |
| No-tool (respond directly) | 87.5% |
| OVERALL | 94.4% |