Instructions to use Trelis/gemma-4-E4B-it-conversational with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Trelis/gemma-4-E4B-it-conversational with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Trelis/gemma-4-E4B-it-conversational") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Trelis/gemma-4-E4B-it-conversational") model = AutoModelForMultimodalLM.from_pretrained("Trelis/gemma-4-E4B-it-conversational", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Trelis/gemma-4-E4B-it-conversational with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M # Run inference directly in the terminal: llama cli -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M # Run inference directly in the terminal: llama cli -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Use Docker
docker model run hf.co/Trelis/gemma-4-E4B-it-conversational:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Trelis/gemma-4-E4B-it-conversational with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Trelis/gemma-4-E4B-it-conversational" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Trelis/gemma-4-E4B-it-conversational", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Trelis/gemma-4-E4B-it-conversational:Q4_K_M
- SGLang
How to use Trelis/gemma-4-E4B-it-conversational with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Trelis/gemma-4-E4B-it-conversational" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Trelis/gemma-4-E4B-it-conversational", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Trelis/gemma-4-E4B-it-conversational" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Trelis/gemma-4-E4B-it-conversational", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Trelis/gemma-4-E4B-it-conversational with Ollama:
ollama run hf.co/Trelis/gemma-4-E4B-it-conversational:Q4_K_M
- Unsloth Desktop
- Pi
How to use Trelis/gemma-4-E4B-it-conversational with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Trelis/gemma-4-E4B-it-conversational:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Trelis/gemma-4-E4B-it-conversational with Docker Model Runner:
docker model run hf.co/Trelis/gemma-4-E4B-it-conversational:Q4_K_M
- Lemonade
How to use Trelis/gemma-4-E4B-it-conversational with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Run and chat with the model
lemonade run user.gemma-4-E4B-it-conversational-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Trelis/gemma-4-E4B-it-conversational with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
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:9931/v1 hermes config set model.default Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Trelis/gemma-4-E4B-it-conversational with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Trelis/gemma-4-E4B-it-conversational:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "Trelis/gemma-4-E4B-it-conversational:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Request model access
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
By requesting access, you confirm your intended use qualifies under the PolyForm Small Business License or is covered by written permission from Trelis Research. You agree to share your details with Trelis and receive one access email.
Log in or Sign Up to review the conditions and access this model content.
gemma-4-E4B-it-conversational
Try Conversational Gemma via API: trelis.com/api/conversational-gemma (OpenAI-compatible chat completions and tool calling; sign in at console.trelis.com).
Use this model to play the caller in a practice conversation or run a compact conversational voice assistant with tool calling. A sales rep can interview a fictional buyer about their needs; a clinician can practice taking a history from a fictional patient using a clinician-reviewed case. The trainee asks the questions, and the caller answers from the case one turn at a time using natural spoken phrasing.
This repository packages standalone merged BF16 weights based on Gemma 4 E4B Instruct alongside text-only GGUF quantizations (Q8_0, Q6_K, and Q4_K_M) for local inference with llama.cpp, Ollama, or LM Studio.
Files and quantization options
For cloud GPU serving, online FP8 quantization in vLLM (--quantization fp8 --limit-mm-per-prompt '{"image":0,"audio":0}') loads in 10.84 GiB of VRAM and holds 62/64 whole-call pass (96.9%) and 91.13% tool accuracy, leaving ample KV cache headroom on a single 48 GB L40S GPU. For local text-only deployment, Q8_0 (7.97 GB) achieves 32/32 openings, 61/64 whole-call pass, and 90.87% tool accuracy (0 malformed), Q6_K (6.17 GB) balances size and precision, and Q4_K_M (5.30 GB) holds 62/64 whole-call pass (96.9%) and 92.14% tool accuracy with zero runaways or repetition loops.
| File / format | Size | SHA-256 | Recommended use |
|---|---|---|---|
| Standalone BF16 safetensors (repo root) | 15.91 GB |
- | GPU serving (vLLM BF16 or online FP8, transformers, or MLX conversion) |
gemma-4-E4B-it-conversational-Q8_0.gguf |
7.97 GB |
5d7d12323deee386104239fbc732872aee1287e22c7f51089e89f9223b534410 |
Highest-precision local quant (32/32 openings, 0 malformed tool calls) |
gemma-4-E4B-it-conversational-Q6_K.gguf |
6.17 GB |
31b36283228bb10e844a41cdb8e06cac8053109380bf290838aae7016e78bc8d |
Balanced local footprint and precision |
gemma-4-E4B-it-conversational-Q4_K_M.gguf |
5.30 GB |
1244c9c708af4753517420746a75b38b88f6c5df85858c88ddb9f9aa8c306f94 |
Compact local serving (62/64 whole-call pass, 92.14% tool accuracy) |
Benchmarks
All arms below were evaluated on the same two suites:
- Held-out simulated caller suite:
32held-out phone scenarios across2random seeds (64full calls, up to20turns each) against a stock Gemma 4 31B support agent with four agent personas (helpful,rude,wrong,interrupting). All64-call transcripts and32two-turn openings across all arms were graded together in one blinded, shuffled run ongemini-3.8-flash(thinking_level="low", provider default temperature,0judge errors). - Tool-calling replay suite:
789unforced tool-calling attempts (263held-out multi-turn cases x3seeds) scored on exact decision agreement and malformed tool syntax. - Spoken-phone perplexity (
Val PPL): held-out600-turn spoken telephone validation set (val.jsonl). Stockgoogle/gemma-4-E4B-itscores57.95on this set; this release scores13.96.
| Model / Precision | Tool acc /789 (malformed) | Openings /32 | Role /64 | Facts /64 | Goal /64 | Delivery /64 | Whole-call pass /64 | Runaways / Rep loops | Median words/turn |
|---|---|---|---|---|---|---|---|---|---|
google/gemma-4-31B-it (stock 31B ref) |
95.18% (1) |
32/32 |
64 |
63 |
64 |
64 |
63/64 |
0 / 0 |
21.0 |
Trelis/gemma-4-31B-it-conversational (31B ref) |
93.16% (2) |
27/32 |
64 |
64 |
61 |
63 |
61/64 |
0 / 3 |
14.0 |
| This release (BF16, vLLM) | 91.63% (0) |
32/32 |
64 |
64 |
63 |
64 |
63/64 |
0 / 0 |
17.0 |
| This release (FP8, vLLM online) | 91.13% (1) |
31/32 |
64 |
63 |
64 |
63 |
62/64 |
0 / 1 |
17.0 |
This release (Q8_0 GGUF, -fa off) |
90.87% (0) |
32/32 |
64 |
62 |
63 |
64 |
61/64 |
0 / 0 |
19.0 |
This release (Q4_K_M GGUF, -fa off) |
92.14% (4) |
30/32 |
64 |
62 |
64 |
64 |
62/64 |
0 / 0 |
19.0 |
Caller: the model is the person calling
Write the caller's facts, then describe what they say up front and what the trainee has to ask about. To reproduce the standard phone-caller prompt and end_call schema locally, use caller.json:
import json
from pathlib import Path
from huggingface_hub import hf_hub_download
caller = json.loads(Path(hf_hub_download("Trelis/gemma-4-E4B-it-conversational", "caller.json")).read_text())
card = caller["card"] # Replace with your own caller facts and opening instructions.
system = caller["system"].replace("<<CALLER>>", card.strip() + "\n\n" + caller["style"])
messages = [
{"role": "system", "content": system},
{"role": "user", "content": "Thanks for calling the shop. How can I help?"},
]
tools = caller["tools"]
The trainee speaks as user; the generated assistant message is the caller. When the caller invokes end_call, its farewell argument is the spoken goodbye.
Assistant: the model is the person answering
Use the same chat template. Replace the caller card and speaking instructions with the assistant's job, what it needs to ask, and when to use its tools. Now user is the caller, and assistant is the support agent. Pass the tool schema separately:
messages = [
{
"role": "system",
"content": "You answer repair calls for a bike shop. Ask for the ticket number if it is missing. To check repair status, use lookup_repair and tell the caller what it returns.",
},
{"role": "user", "content": "Is my repair ready? My ticket is B42."},
]
tools = [
{
"type": "function",
"function": {
"name": "lookup_repair",
"description": "Look up the status of a repair ticket.",
"parameters": {
"type": "object",
"properties": {"ticket": {"type": "string"}},
"required": ["ticket"],
},
},
}
]
Your app executes the requested tool, appends the assistant's tool_calls message, appends a role: "tool" message with the matching tool_call_id and tool result, and renders again to generate the spoken reply. When rendering locally with apply_chat_template, pass a Python dictionary for function.arguments.
Load and serve the model
Transformers (BF16)
from transformers import AutoModelForImageTextToText, AutoTokenizer
name = "Trelis/gemma-4-E4B-it-conversational"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForImageTextToText.from_pretrained(name, device_map="cuda", dtype="bfloat16")
inputs = tokenizer.apply_chat_template(
messages,
tools=tools,
add_generation_prompt=True,
enable_thinking=False,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
output = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=1.0, top_p=0.95, top_k=64)
print(tokenizer.decode(output[0, inputs.input_ids.shape[1]:], skip_special_tokens=False))
vLLM (recommended cloud serving: online FP8 on L40S / H100)
vllm serve Trelis/gemma-4-E4B-it-conversational \
--dtype bfloat16 \
--quantization fp8 \
--max-model-len 12288 \
--limit-mm-per-prompt '{"image":0,"audio":0}' \
--enable-prefix-caching \
--enable-auto-tool-choice \
--tool-call-parser gemma4
Omit --quantization fp8 to serve in BF16. Send structured messages (and tools when needed) to /v1/chat/completions with chat_template_kwargs: {"enable_thinking": false} and Gemma decoding (temperature=1.0, top_p=0.95, top_k=64). On vLLM 0.34.0, online FP8 quantization takes 0.14s at load time and uses 10.84 GiB of GPU memory for weights.
llama.cpp (GGUF)
llama-server -hf Trelis/gemma-4-E4B-it-conversational:Q8_0 \
--port 8080 -ngl 99 -c 16384 -fa off --jinja
Important
llama.cppCUDA note: Pass-fa offwhen serving Gemma 4 E4B GGUF weights on CUDA GPUs. Upstreamllama.cppCUDA Flash Attention can corrupt Gemma 4 E4B's mixedhead_dim=512global andhead_dim=256sliding-window layers into repetition loops.
Training summary
This checkpoint was trained in three stages on the language-model layers of google/gemma-4-E4B-it (leaving vision and audio towers unmodified):
- Expanded rejection-sampled distillation SFT: Shuffled LoRA fine-tuning (
r=64, alpha=128) on28,560mixed turns built from2,558gold and272silver synthetic phone calls generated by Conversational Gemma 4 31B (save 74) across989unique training scenarios (combined from202original training scenarios and831newly authored split-clean scenarios), anchored with1,500spoken telephone turns,2xmulti-turn Dialt tool examples (3,554rows), and2xteacher-verified leak-freeWhen2Callvoice-assistant tool examples (4,212rows). - Full-sequence reverse-KL tool OPD (
40steps): On-policy reverse-KL distillation from frozen stockgoogle/gemma-4-31B-itover full assistant responses with2xcall-trigger weighting across2,946Dialt andWhen2Calltool turns, paired with a0.35gold caller anchor (91.76%tool accuracy,0malformed calls). - On-policy caller DPO polish (
24steps): Generated700on-policy rollouts from the Stage 2 checkpoint across350training scenarios, identified failing turns withgemini-3.8-flash, synthesized and verified224exact shared-promptsave 74replacement turns, and trained length-normalized DPO (beta=0.10) with a positive SFT anchor (0.15) and a verified tool-calling CE anchor (0.35), raising whole-call pass to63/64(32/32openings,64/64facts,0loops) while preserving91.63%tool accuracy (0malformed,0schema failures).
Limitations
- Tuned for spoken English phone conversations; non-English performance and formal long-form writing were not targeted.
- Tool accuracy (
91.63%BF16,91.13%FP8) trails the 31B flagship (93.16%) by roughly 1.5 points, primarily through conservative missed calls (0malformed syntax errors and0schema failures in BF16). - The
Q4_K_MGGUF introduces a small number of malformed tool calls (4/789); preferQ8_0(0/789malformed) orQ6_Kfor strict local tool-calling workflows. - The GGUF files contain text-only weights (multimodal encoders omitted for smaller local downloads).
License
The conversational modifications are offered under the PolyForm Small Business License 1.0.0. The original Gemma 4 E4B Instruct weights are licensed under Apache 2.0. This repository incorporates the conversational modifications in merged BF16 and text-only GGUF formats.
- Downloads last month
- 30