Instructions to use williamliao/gemma-4-12B-it-DFlash-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="williamliao/gemma-4-12B-it-DFlash-GGUF", filename="gemma-4-12B-it-DFlash-F16.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 williamliao/gemma-4-12B-it-DFlash-GGUF 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 williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
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 williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
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 williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
Use Docker
docker model run hf.co/williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "williamliao/gemma-4-12B-it-DFlash-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": "williamliao/gemma-4-12B-it-DFlash-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
- Ollama
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with Ollama:
ollama run hf.co/williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
- Unsloth Studio
How to use williamliao/gemma-4-12B-it-DFlash-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 williamliao/gemma-4-12B-it-DFlash-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 williamliao/gemma-4-12B-it-DFlash-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for williamliao/gemma-4-12B-it-DFlash-GGUF to start chatting
- Pi
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
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": "williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf williamliao/gemma-4-12B-it-DFlash-GGUF: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:8080/v1 hermes config set model.default williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf williamliao/gemma-4-12B-it-DFlash-GGUF: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:8080/v1 \ --custom-model-id "williamliao/gemma-4-12B-it-DFlash-GGUF: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"
- Docker Model Runner
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with Docker Model Runner:
docker model run hf.co/williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
- Lemonade
How to use williamliao/gemma-4-12B-it-DFlash-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull williamliao/gemma-4-12B-it-DFlash-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.gemma-4-12B-it-DFlash-GGUF-Q4_K_M
List all available models
lemonade list
gemma4-12B-it-DFlash-GGUF
GGUF conversion of z-lab/gemma4-12B-it-DFlash for use with llama.cpp.
This is a DFlash draft model, not a standalone language model.
It must be used together with a compatible google/gemma-4-12B-it GGUF target model.
Model Details
- Source model:
z-lab/gemma4-12B-it-DFlash - Compatible target:
google/gemma-4-12B-it - Format: GGUF
- Quantization: Q4_K_M
- Purpose: DFlash speculative decoding
This repository contains only the DFlash draft model. It does not include the Gemma 4 12B target model.
Compatibility
A recent version of llama.cpp with DFlash support is required.
Tested with:
- llama.cpp b9831
- NVIDIA GeForce RTX 5070 Ti 16 GB
- Target model:
gemma-4-12b-it-UD-Q4_K_XL
Other llama.cpp builds, target quantizations, hardware configurations, prompts, and sampling settings may produce different performance.
Usage
llama-server
llama-server \
-m gemma-4-12b-it-UD-Q4_K_XL.gguf \
-md gemma4-12B-it-DFlash-Q4_K_M.gguf \
--spec-type draft-dflash \
--spec-draft-n-max 4
llama-cli
llama-cli \
-m gemma-4-12b-it-UD-Q4_K_XL.gguf \
-md gemma4-12B-it-DFlash-Q4_K_M.gguf \
--spec-type draft-dflash \
--spec-draft-n-max 4
The target and draft models must use the same tokenizer and vocabulary.
Suggested Settings
Based on the benchmark below:
n_max = 4gave the best aggregate wall-clock result.n_max = 2gave the highest overall acceptance rate and performed better on several high-entropy natural-language tasks.n_max = 4–5performed well for predictable outputs such as code completion, JSON, and repeated patterns.n_max = 5improved a few highly structured tasks, but was slower overall thann_max = 4in this mixed benchmark.
A reasonable general starting point is:
--spec-draft-n-max 4
For translation, creative writing, explanations, or conversational output, n_max = 2 may be preferable. For JSON and highly predictable output, n_max = 4–5 may perform better. For general code completion, n_max = 3–4 may be a better starting point.
Conversion
Converted from the original Hugging Face DFlash checkpoint using convert_hf_to_gguf.py.
Gemma 4 tokenizer metadata was loaded from the compatible target model directory through --target-model-dir.
No neural-network weights were edited or retrained. The weights were converted and quantized to GGUF format.
Benchmark
Benchmarked using mtp-bench on an NVIDIA GeForce RTX 5070 Ti.
Target model:
gemma-4-12b-it-UD-Q4_K_XL
Draft model:
gemma4-12B-it-DFlash-Q4_K_M
Aggregate Results
n_max |
Draft acceptance | Predicted tokens | Draft tokens | Accepted tokens | Wall time |
|---|---|---|---|---|---|
| 2 | 67.6% | 1,975 | 1,668 | 1,128 | 19.50 s |
| 3 | 57.5% | 1,975 | 2,159 | 1,241 | 19.29 s |
| 4 | 51.0% | 1,976 | 2,582 | 1,316 | 18.81 s |
| 5 | 42.7% | 1,976 | 3,125 | 1,334 | 20.45 s |
These results do not include a non-speculative baseline and therefore should not be interpreted as a direct speedup ratio over standard decoding.
Performance varies substantially by task type.
Detailed Results
n_max = 2
code_python pred= 192 draft= 157 acc= 112 rate=0.713 tok/s=112.2
code_cpp pred= 192 draft= 152 acc= 115 rate=0.757 tok/s=123.0
explain_concept pred= 192 draft= 190 acc= 95 rate=0.500 tok/s=98.1
summarize pred= 43 draft= 38 acc= 24 rate=0.632 tok/s=110.2
qa_factual pred= 160 draft= 148 acc= 85 rate=0.574 tok/s=104.5
translation pred= 26 draft= 32 acc= 10 rate=0.312 tok/s=78.2
creative_short pred= 44 draft= 56 acc= 15 rate=0.268 tok/s=77.0
stepwise_math pred= 192 draft= 145 acc= 118 rate=0.814 tok/s=128.3
json_output pred= 192 draft= 134 acc= 124 rate=0.925 tok/s=134.3
long_reasoning pred= 192 draft= 155 acc= 113 rate=0.729 tok/s=115.2
repeat_pattern pred= 192 draft= 130 acc= 126 rate=0.969 tok/s=141.6
code_completion pred= 166 draft= 128 acc= 102 rate=0.797 tok/s=125.2
long_code_review pred= 192 draft= 203 acc= 89 rate=0.438 tok/s=88.7
Aggregate:
requests: 13
predicted tokens: 1975
draft tokens: 1668
accepted tokens: 1128
acceptance rate: 0.6763
total wall time: 19.50 s
n_max = 3
code_python pred= 192 draft= 206 acc= 122 rate=0.592 tok/s=114.0
code_cpp pred= 192 draft= 197 acc= 125 rate=0.634 tok/s=122.0
explain_concept pred= 192 draft= 261 acc= 103 rate=0.395 tok/s=92.3
summarize pred= 43 draft= 48 acc= 27 rate=0.562 tok/s=112.3
qa_factual pred= 160 draft= 201 acc= 93 rate=0.463 tok/s=98.0
translation pred= 26 draft= 45 acc= 10 rate=0.222 tok/s=69.8
creative_short pred= 44 draft= 78 acc= 18 rate=0.231 tok/s=70.4
stepwise_math pred= 192 draft= 186 acc= 129 rate=0.694 tok/s=130.2
json_output pred= 192 draft= 155 acc= 139 rate=0.897 tok/s=152.4
long_reasoning pred= 192 draft= 195 acc= 125 rate=0.641 tok/s=122.0
repeat_pattern pred= 192 draft= 146 acc= 142 rate=0.973 tok/s=162.2
code_completion pred= 166 draft= 156 acc= 114 rate=0.731 tok/s=132.7
long_code_review pred= 192 draft= 285 acc= 94 rate=0.330 tok/s=79.3
Aggregate:
requests: 13
predicted tokens: 1975
draft tokens: 2159
accepted tokens: 1241
acceptance rate: 0.5748
total wall time: 19.29 s
n_max = 4
code_python pred= 192 draft= 257 acc= 126 rate=0.490 tok/s=112.7
code_cpp pred= 192 draft= 220 acc= 135 rate=0.614 tok/s=132.7
explain_concept pred= 192 draft= 304 acc= 114 rate=0.375 tok/s=96.4
summarize pred= 46 draft= 68 acc= 29 rate=0.426 tok/s=102.9
qa_factual pred= 162 draft= 248 acc= 100 rate=0.403 tok/s=101.8
translation pred= 26 draft= 56 acc= 12 rate=0.214 tok/s=70.8
creative_short pred= 44 draft= 100 acc= 19 rate=0.190 tok/s=68.8
stepwise_math pred= 192 draft= 219 acc= 136 rate=0.621 tok/s=133.6
json_output pred= 192 draft= 176 acc= 146 rate=0.830 tok/s=163.8
long_reasoning pred= 192 draft= 228 acc= 133 rate=0.583 tok/s=127.3
repeat_pattern pred= 192 draft= 163 acc= 149 rate=0.914 tok/s=174.7
code_completion pred= 162 draft= 196 acc= 113 rate=0.577 tok/s=127.3
long_code_review pred= 192 draft= 347 acc= 104 rate=0.300 tok/s=80.2
Aggregate:
requests: 13
predicted tokens: 1976
draft tokens: 2582
accepted tokens: 1316
acceptance rate: 0.5097
total wall time: 18.81 s
n_max = 5
code_python pred= 192 draft= 285 acc= 133 rate=0.467 tok/s=112.0
code_cpp pred= 192 draft= 285 acc= 134 rate=0.470 tok/s=116.8
explain_concept pred= 192 draft= 384 acc= 113 rate=0.294 tok/s=85.5
summarize pred= 46 draft= 85 acc= 29 rate=0.341 tok/s=92.6
qa_factual pred= 162 draft= 310 acc= 100 rate=0.323 tok/s=90.3
translation pred= 26 draft= 70 acc= 12 rate=0.171 tok/s=62.9
creative_short pred= 44 draft= 125 acc= 19 rate=0.152 tok/s=58.6
stepwise_math pred= 192 draft= 257 acc= 139 rate=0.541 tok/s=124.4
json_output pred= 192 draft= 182 acc= 154 rate=0.846 tok/s=171.4
long_reasoning pred= 192 draft= 274 acc= 135 rate=0.493 tok/s=115.3
repeat_pattern pred= 192 draft= 173 acc= 155 rate=0.896 tok/s=175.2
code_completion pred= 162 draft= 225 acc= 117 rate=0.520 tok/s=120.2
long_code_review pred= 192 draft= 470 acc= 94 rate=0.200 tok/s=67.8
Aggregate:
requests: 13
predicted tokens: 1976
draft tokens: 3125
accepted tokens: 1334
acceptance rate: 0.4269
total wall time: 20.45 s
Observations
n_max = 2achieved the highest aggregate draft acceptance rate.n_max = 4achieved the shortest total wall time in this mixed benchmark.n_max = 3was close ton_max = 4while using fewer draft tokens.n_max = 5improved JSON output and repeated-pattern generation, but increased total wall time.- Translation, creative writing, conceptual explanations, and long-form code review showed substantially lower acceptance as
n_maxincreased. - General code completion peaked at
n_max = 3in this benchmark, while JSON and repeated patterns benefited from longer draft sequences.
Notes
This repository contains only the DFlash draft model.
A compatible google/gemma-4-12B-it GGUF target model is required. The target GGUF may use a different quantization from the draft model, but both models must share compatible tokenizer and model architecture assumptions.
The benchmark results are specific to the tested hardware, model quantizations, llama.cpp build, prompts, and runtime settings.
Credits
- Z Lab — DFlash method and original draft checkpoint
- Google DeepMind — Gemma 4 and
google/gemma-4-12B-it - ggml-org — llama.cpp, GGUF, and DFlash inference support
License
This repository contains a converted and quantized GGUF version of the original DFlash draft checkpoint.
The upstream z-lab/gemma4-12B-it-DFlash and google/gemma-4-12B-it repositories identify their applicable licensing terms. Users should review the upstream model cards and licenses before redistribution or commercial use.
- Downloads last month
- 1,687
4-bit
5-bit
6-bit
8-bit
16-bit