Instructions to use husj576/TEV-gemma4-it-12B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use husj576/TEV-gemma4-it-12B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="husj576/TEV-gemma4-it-12B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("husj576/TEV-gemma4-it-12B") model = AutoModel.from_pretrained("husj576/TEV-gemma4-it-12B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use husj576/TEV-gemma4-it-12B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "husj576/TEV-gemma4-it-12B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "husj576/TEV-gemma4-it-12B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/husj576/TEV-gemma4-it-12B
- SGLang
How to use husj576/TEV-gemma4-it-12B 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 "husj576/TEV-gemma4-it-12B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "husj576/TEV-gemma4-it-12B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "husj576/TEV-gemma4-it-12B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "husj576/TEV-gemma4-it-12B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use husj576/TEV-gemma4-it-12B with Docker Model Runner:
docker model run hf.co/husj576/TEV-gemma4-it-12B
TEV Draft Model for Gemma 4 12B IT
Paper: Where Draft Trees Lose Target Mass: Exit-Guided Speculative Decoding
This repository contains the ExitTrain-trained DFlash draft model for google/gemma-4-12B-it, released with TEV: Exit-Guided Speculative Decoding.
GitHub | DDTree + TEV guide | Gemma 4 setup
This is a draft model, not a standalone language model. It must be paired with the matching Gemma 4 12B instruction-tuned target model in a speculative decoding system.
Model details
| Field | Value |
|---|---|
| Target model | google/gemma-4-12B-it |
| Target interface | Gemma 4 unified, text-only benchmark path |
| Draft architecture | DFlashDraftModel |
| Training method | ExitTrain |
| Tree builder and verifier | DDTree + TEV |
| Draft block size | 16 |
| Target layers | 48 |
| Target feature layers | [1, 10, 19, 27, 36, 45] |
| Draft hidden size | 3840 |
| Target logit soft cap | 30.0 |
| Precision | BF16 |
ExitTrain trains the drafter on its realized finite-budget draft trees. Target probabilities are evaluated under the actual tree-parent contexts, and target-derived exit feedback is used to improve where the bounded tree allocates its nodes.
Quick start with DDTree + TEV
Gemma 4 requires a recent Transformers release and may require accepting the target model's Hugging Face terms.
git clone https://github.com/hsj576/TEV.git
cd TEV/ddtree
pip install -r requirements.txt
pip install -U "transformers>=5.11"
# Run `hf auth login` first if access to the target is gated.
export TARGET_MODEL=google/gemma-4-12B-it
export DRAFT_MODEL=husj576/TEV-gemma4-it-12B
bash scripts/run_ddtree_tev_smoke.sh
Direct benchmark command
torchrun --nproc_per_node=1 --master_port=29700 benchmark.py \
--model-name-or-path google/gemma-4-12B-it \
--draft-name-or-path husj576/TEV-gemma4-it-12B \
--dataset gsm8k \
--max-samples 128 \
--max-new-tokens 2048 \
--temperature 1.0 \
--tree-budget 64 \
--save-path runs/gemma4_12b/gsm8k__t1_0__tb64.pt
Do not pass --flash-attn to benchmark.py: the target must use SDPA to consume DDTree's custom tree mask. The draft model still uses FlashAttention.
Gemma 4 compatibility
The TEV repository adds a compatibility path in ddtree/model/target_loader.py that:
- loads the unified model through
AutoModelForImageTextToText; - extracts the language backbone and LM head behind a causal-LM-like wrapper;
- makes the target KV cache compatible with DDTree's full-length tree mask;
- disables sliding-window KV trimming during this benchmark path.
This implementation is currently text-only and does not process image or audio inputs.
For compatibility with the full-length DDTree mask, sliding-attention layers are promoted to full attention at runtime. This can increase memory and runtime. Once a sequence exceeds Gemma 4's native sliding window, the target forward differs from native Gemma 4 behavior, although all comparison paths in this benchmark use the same loaded target.
See the Gemma 4 DDTree guide for details and troubleshooting.
Usage notes
- Use this checkpoint only with
google/gemma-4-12B-it. - At positive temperature, the DDTree branch uses TEV sampling. At temperature
0, it uses the equivalent greedy tree-follow path. - The current reference implementation targets batch-one decoding and places the target and draft models on the same GPU.
- Gemma 4 12B, its draft model, the full target KV cache, and the draft tree require substantial GPU memory. Start with a smaller tree budget and generation length if needed.
Related checkpoints
Acknowledgements
- Downloads last month
- 70