Text Generation
Transformers
Safetensors
English
gemma4
image-text-to-text
cerebras
expert-pruning
gemma
Mixture of Experts
pruning
reap
conversational
Instructions to use 0xSero/Gemma-4-21B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0xSero/Gemma-4-21B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="0xSero/Gemma-4-21B") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("0xSero/Gemma-4-21B") model = AutoModelForMultimodalLM.from_pretrained("0xSero/Gemma-4-21B", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 0xSero/Gemma-4-21B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "0xSero/Gemma-4-21B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0xSero/Gemma-4-21B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/0xSero/Gemma-4-21B
- SGLang
How to use 0xSero/Gemma-4-21B 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 "0xSero/Gemma-4-21B" \ --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": "0xSero/Gemma-4-21B", "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 "0xSero/Gemma-4-21B" \ --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": "0xSero/Gemma-4-21B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 0xSero/Gemma-4-21B with Docker Model Runner:
docker model run hf.co/0xSero/Gemma-4-21B
Standardize model card (template rollout)
Browse files
README.md
CHANGED
|
@@ -3,28 +3,52 @@ language:
|
|
| 3 |
- en
|
| 4 |
license: gemma
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
| 7 |
- gemma4
|
| 8 |
- moe
|
| 9 |
- pruning
|
| 10 |
- reap
|
| 11 |
-
-
|
| 12 |
-
- expert-pruning
|
| 13 |
base_model:
|
| 14 |
- google/gemma-4-26b-a4b-it
|
| 15 |
library_name: transformers
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
---
|
|
|
|
| 18 |
> [!TIP]
|
| 19 |
-
> Support this work
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
**20% expert-pruned** version of [google/gemma-4-26b-a4b-it](https://huggingface.co/google/gemma-4-26b-a4b-it) using **[Cerebras REAP](https://github.com/cerebras/reap)** (Router-weighted Expert Activation Pruning).
|
| 26 |
|
| 27 |
-
| | Original | This Model (0.20) | [0.30 variant](https://huggingface.co/0xSero/
|
| 28 |
|---|---:|---:|---:|
|
| 29 |
| **Total params** | ~26B | **21.34B** | 19.02B |
|
| 30 |
| **Experts per layer** | 128 | **103** | 90 |
|
|
@@ -131,7 +155,7 @@ Gemma 4 uses a hybrid sliding/full attention MoE architecture:
|
|
| 131 |
```python
|
| 132 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 133 |
|
| 134 |
-
model_id = "0xSero/
|
| 135 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 136 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto", trust_remote_code=True)
|
| 137 |
|
|
@@ -147,7 +171,7 @@ print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_toke
|
|
| 147 |
```bash
|
| 148 |
pip install vllm>=0.19 transformers>=5.0
|
| 149 |
|
| 150 |
-
vllm serve 0xSero/
|
| 151 |
--tensor-parallel-size 2 \
|
| 152 |
--enforce-eager \
|
| 153 |
--gpu-memory-utilization 0.9 \
|
|
@@ -155,31 +179,24 @@ vllm serve 0xSero/gemma-4-21b-a4b-it-REAP \
|
|
| 155 |
--trust-remote-code
|
| 156 |
```
|
| 157 |
|
| 158 |
-
## Citation
|
| 159 |
-
|
| 160 |
-
```bibtex
|
| 161 |
-
@inproceedings{lasby2025reap,
|
| 162 |
-
title={{REAP} the Experts: Why Pruning Prevails for One-Shot {MoE} Compression},
|
| 163 |
-
author={Lasby, Mike and others},
|
| 164 |
-
booktitle={International Conference on Learning Representations (ICLR)},
|
| 165 |
-
year={2026},
|
| 166 |
-
url={https://arxiv.org/abs/2510.13999}
|
| 167 |
-
}
|
| 168 |
-
```
|
| 169 |
|
| 170 |
## Links
|
| 171 |
|
| 172 |
- **REAP paper:** [arxiv.org/abs/2510.13999](https://arxiv.org/abs/2510.13999)
|
| 173 |
- **REAP code:** [github.com/cerebras/reap](https://github.com/cerebras/reap)
|
| 174 |
-
- **30% pruned variant:** [0xSero/
|
| 175 |
- **Base model:** [google/gemma-4-26b-a4b-it](https://huggingface.co/google/gemma-4-26b-a4b-it)
|
| 176 |
|
| 177 |
-
##
|
|
|
|
| 178 |
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
- Lambda
|
| 184 |
-
- Prime Intellect
|
| 185 |
-
- HotAisle
|
|
|
|
| 3 |
- en
|
| 4 |
license: gemma
|
| 5 |
tags:
|
| 6 |
+
- cerebras
|
| 7 |
+
- expert-pruning
|
| 8 |
+
- gemma
|
| 9 |
- gemma4
|
| 10 |
- moe
|
| 11 |
- pruning
|
| 12 |
- reap
|
| 13 |
+
- safetensors
|
|
|
|
| 14 |
base_model:
|
| 15 |
- google/gemma-4-26b-a4b-it
|
| 16 |
library_name: transformers
|
| 17 |
pipeline_tag: text-generation
|
| 18 |
---
|
| 19 |
+
|
| 20 |
> [!TIP]
|
| 21 |
+
> **[Support this work →](https://donate.sybilsolutions.ai)** · [X](https://x.com/0xsero) · [GitHub](https://github.com/0xsero) · [REAP paper](https://arxiv.org/abs/2510.13999) · [Cerebras REAP](https://huggingface.co/collections/cerebras/cerebras-reap)
|
| 22 |
+
|
| 23 |
+
# Gemma-4-21B
|
| 24 |
+
|
| 25 |
+
REAP-pruned [google/gemma-4-26b-a4b-it](https://huggingface.co/google/gemma-4-26b-a4b-it).
|
| 26 |
+
|
| 27 |
+
## At a glance
|
| 28 |
+
|
| 29 |
+
| | |
|
| 30 |
+
|---|---|
|
| 31 |
+
| Base model | — |
|
| 32 |
+
| Format | BF16 |
|
| 33 |
+
| Total params | **21B** |
|
| 34 |
+
| Active / token | — |
|
| 35 |
+
| Experts / layer | 103 |
|
| 36 |
+
| Layers | — |
|
| 37 |
+
| Hidden size | — |
|
| 38 |
+
| Context | — |
|
| 39 |
+
| On-disk size | 43 GB |
|
| 40 |
|
| 41 |
+
## Which variant should I pick?
|
| 42 |
+
|
| 43 |
+
| Variant | Format | Link |
|
| 44 |
+
|---|---|---|
|
| 45 |
+
| `Gemma-4-19B` | BF16 | [link](https://huggingface.co/0xSero/Gemma-4-19B) |
|
| 46 |
+
| `Gemma-4-21B` **(this)** | BF16 | [link](https://huggingface.co/0xSero/Gemma-4-21B) |
|
| 47 |
+
| `gemma-moe-reap` | BF16 | [link](https://huggingface.co/0xSero/gemma-moe-reap) |
|
| 48 |
|
| 49 |
**20% expert-pruned** version of [google/gemma-4-26b-a4b-it](https://huggingface.co/google/gemma-4-26b-a4b-it) using **[Cerebras REAP](https://github.com/cerebras/reap)** (Router-weighted Expert Activation Pruning).
|
| 50 |
|
| 51 |
+
| | Original | This Model (0.20) | [0.30 variant](https://huggingface.co/0xSero/Gemma-4-19B) |
|
| 52 |
|---|---:|---:|---:|
|
| 53 |
| **Total params** | ~26B | **21.34B** | 19.02B |
|
| 54 |
| **Experts per layer** | 128 | **103** | 90 |
|
|
|
|
| 155 |
```python
|
| 156 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 157 |
|
| 158 |
+
model_id = "0xSero/Gemma-4-21B"
|
| 159 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 160 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto", trust_remote_code=True)
|
| 161 |
|
|
|
|
| 171 |
```bash
|
| 172 |
pip install vllm>=0.19 transformers>=5.0
|
| 173 |
|
| 174 |
+
vllm serve 0xSero/Gemma-4-21B \
|
| 175 |
--tensor-parallel-size 2 \
|
| 176 |
--enforce-eager \
|
| 177 |
--gpu-memory-utilization 0.9 \
|
|
|
|
| 179 |
--trust-remote-code
|
| 180 |
```
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
## Links
|
| 184 |
|
| 185 |
- **REAP paper:** [arxiv.org/abs/2510.13999](https://arxiv.org/abs/2510.13999)
|
| 186 |
- **REAP code:** [github.com/cerebras/reap](https://github.com/cerebras/reap)
|
| 187 |
+
- **30% pruned variant:** [0xSero/Gemma-4-19B](https://huggingface.co/0xSero/Gemma-4-19B)
|
| 188 |
- **Base model:** [google/gemma-4-26b-a4b-it](https://huggingface.co/google/gemma-4-26b-a4b-it)
|
| 189 |
|
| 190 |
+
## License & citation
|
| 191 |
+
License inherited from the base model.
|
| 192 |
|
| 193 |
+
```bibtex
|
| 194 |
+
@misc{lasby2025reap,
|
| 195 |
+
title = {REAP the Experts: Why Pruning Prevails for One-Shot MoE Compression},
|
| 196 |
+
author = {Mike Lasby and Ivan Lazarevich and Nish Sinnadurai and Sean Lie and Yani Ioannou and Vithursan Thangarasa},
|
| 197 |
+
year = {2025}, eprint = {2510.13999}, archivePrefix = {arXiv}
|
| 198 |
+
}
|
| 199 |
+
```
|
| 200 |
|
| 201 |
+
## Sponsors
|
| 202 |
+
Made possible by **NVIDIA · TNG Technology · Lambda · Prime Intellect · Hot Aisle**.
|
|
|
|
|
|
|
|
|