Instructions to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="roshangrewal/gemma4-e4b-toolcall-v02-gguf", filename="gemma4-toolcall-v02-Q8_0.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0 # Run inference directly in the terminal: llama-cli -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0 # Run inference directly in the terminal: llama-cli -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Use Docker
docker model run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
- LM Studio
- Jan
- vLLM
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "roshangrewal/gemma4-e4b-toolcall-v02-gguf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "roshangrewal/gemma4-e4b-toolcall-v02-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
- Ollama
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Ollama:
ollama run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
- Unsloth Studio
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for roshangrewal/gemma4-e4b-toolcall-v02-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for roshangrewal/gemma4-e4b-toolcall-v02-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for roshangrewal/gemma4-e4b-toolcall-v02-gguf to start chatting
- Pi
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Run Hermes
hermes
- Atomic Chat new
- Docker Model Runner
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Docker Model Runner:
docker model run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
- Lemonade
How to use roshangrewal/gemma4-e4b-toolcall-v02-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull roshangrewal/gemma4-e4b-toolcall-v02-gguf:Q8_0
Run and chat with the model
lemonade run user.gemma4-e4b-toolcall-v02-gguf-Q8_0
List all available models
lemonade list
Gemma 4 E4B — Tool-Calling v0.2 (GGUF)
GGUF quantized version of roshangrewal/gemma4-e4b-toolcall-v02 for use with llama.cpp, Ollama, LM Studio, and other GGUF-compatible runners.
94.4% tool-calling accuracy on 1000 diverse queries. 4B parameters.
Quick Start
Ollama (one command)
ollama run hf.co/roshangrewal/gemma4-e4b-toolcall-v02-gguf
LM Studio
- Open LM Studio
- Search for
roshangrewal/gemma4-e4b-toolcall-v02-ggufin the model browser - Download and start chatting
Note: 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.
Available Quantizations
| File | Quant | Size | Use Case |
|---|---|---|---|
gemma4-toolcall-v02-Q8_0.gguf |
Q8_0 | ~8 GB | Best quality, needs 10GB+ RAM |
⚠️ About the Prompt Format
Gemma 4 uses a custom token format internally that looks different from standard chat templates. When using GGUF directly (without HuggingFace's 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)
Tool definitions use special quote tokens <|"|> instead of normal quotes:
declaration:function_name{description:<|"|>Some description<|"|>,parameters:{...}}
Model output will be in this format:
<|tool_call>call:get_weather{city:<|"|>Mumbai<|"|>}<tool_call|>
This is equivalent to the JSON: {"name": "get_weather", "arguments": {"city": "Mumbai"}}
Tip: If this format looks complex, consider using the full HuggingFace model instead — it has a
processor.apply_chat_template()that handles all formatting automatically from standard JSON.
Usage with llama.cpp
# Download
huggingface-cli download roshangrewal/gemma4-e4b-toolcall-v02-gguf gemma4-toolcall-v02-Q8_0.gguf --local-dir .
# Run inference
./llama-cli -m gemma4-toolcall-v02-Q8_0.gguf \
-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" \
-n 100
Usage with Ollama
# Create a Modelfile
cat > Modelfile << 'EOF'
FROM ./gemma4-toolcall-v02-Q8_0.gguf
TEMPLATE """<|turn>system
{{ .System }}<turn|>
<|turn>user
{{ .Prompt }}<turn|>
<|turn>model
"""
PARAMETER temperature 0
PARAMETER stop "<turn|>"
PARAMETER stop "<eos>"
SYSTEM "You are a helpful assistant with access to tools."
EOF
# Create and run
ollama create gemma4-toolcall -f Modelfile
ollama run gemma4-toolcall "What's the weather in Delhi?"
Usage with Python (llama-cpp-python)
from llama_cpp import Llama
llm = Llama(model_path="gemma4-toolcall-v02-Q8_0.gguf", n_ctx=4096)
# Build prompt in Gemma 4 native format
# Tool definition with special <|"|> quote tokens
prompt = '''<|turn>system
You are a helpful assistant.<|tool>declaration:get_weather{description:<|"|>Get current weather<|"|>,parameters:{properties:{city:{type:<|"|>STRING<|"|>}},required:[<|"|>city<|"|>],type:<|"|>OBJECT<|"|>}}<tool|><turn|>
<|turn>user
What's the weather in Mumbai?<turn|>
<|turn>model
'''
output = llm(prompt, max_tokens=100, stop=["<turn|>", "<eos>"])
print(output["choices"][0]["text"])
# Output: <|tool_call>call:get_weather{city:<|"|>Mumbai<|"|>}<tool_call|>
# Which means: calling get_weather with city="Mumbai"
Parsing the output
import re
response = output["choices"][0]["text"]
# Extract function name and parameters
match = re.search(r"call:(\w+)\{(.+?)\}", response, re.DOTALL)
if match:
function_name = match.group(1) # "get_weather"
params_raw = match.group(2)
# Parse params: key:<|"|>value<|"|> format
params = {}
for key, value in re.findall(r'(\w+):<\|"\|>(.*?)<\|"\|>', params_raw):
params[key] = value
# Also parse numeric params: key:number
for key, value in re.findall(r'(\w+):(\d+(?:\.\d+)?)', params_raw):
if key not in params:
params[key] = float(value) if '.' in value else int(value)
print(f"Function: {function_name}") # get_weather
print(f"Params: {params}") # {"city": "Mumbai"}
else:
# Model chose not to call a tool — responded with text directly
print(f"Response: {response}")
Usage with LM Studio
- Download
gemma4-toolcall-v02-Q8_0.gguf - Open LM Studio → Load Model → Select the GGUF file
- Chat with tool definitions in system prompt
Model Details
- Base model: google/gemma-4-E4B-it (4B parameters)
- Training: QLoRA SFT on 78K (~85 hours) tool-calling examples via Unsloth
- Accuracy: 94.4% on 1000 diverse queries (simple, ambiguous, many-tools, no-tool, complex params)
- Output format: Gemma 4 native tool-call tokens
BFCL Leaderboard (Official)
| 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% |
Performance by Category
| 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% |
Related Models
- Full weights (fp16): roshangrewal/gemma4-e4b-toolcall-v02 — use this if you want automatic prompt formatting
- LoRA adapter: roshangrewal/gemma4-e4b-toolcall-v02-lora
- Base model: google/gemma-4-E4B-it
- Downloads last month
- 59
8-bit