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
File size: 2,105 Bytes
a2083b4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | cluster_args:
cluster_description: null
cluster_method: agglomerative
compression_ratio: 0.2
expert_sim: ttm
frequency_penalty: true
linkage_method: average
max_cluster_size: null
multi_layer: null
num_clusters: null
singleton_outlier_experts: false
singleton_super_experts: false
softmax_temperature: null
ds_args:
dataset_config_name: null
dataset_name: theblackcat102/evol-codealpaca-v1:1000,open-r1/Mixture-of-Thoughts[code]:3480,open-r1/Mixture-of-Thoughts[math]:3578,open-r1/Mixture-of-Thoughts[science]:3576,Salesforce/xlam-function-calling-60k:1000,SWE-bench/SWE-smith-trajectories(tool):1000,qiaojin/PubMedQA[pqa_labeled]:800,derek-thomas/ScienceQA:800,openai/gsm8k[main]:4466,HuggingFaceH4/MATH-500(test):500,evalplus/humanevalplus(test):164,theblackcat102/evol-codealpaca-v1:1636
dataset_test_split: test
shuffle: true
split: train
eval_args:
evalplus_tasks:
- mbpp
- humaneval
greedy: true
lm_eval_tasks:
- winogrande
- arc_challenge
- arc_easy
- boolq
- hellaswag
- mmlu
- openbookqa
- rte
min_p: 0.0
parallel_tasks: 32
results_dir: null
run_evalplus: true
run_livecodebench: true
run_lm_eval: true
run_math: false
run_wildbench: false
server_log_file_name: server.log
temperature: 0.7
top_k: 20
top_p: 0.8
use_server: true
vllm_port: 8000
model_args:
model_name: /mnt/llm_models/gemma-4-26B-A4B-it
num_experts_per_tok_override: null
obs_args:
batch_size: 1
distance_measure: angular
model_max_length: 16384
output_file_name: observations_22k_reap_gemma4.pt
overwrite_observations: false
record_pruning_metrics_only: true
renormalize_router_weights: true
return_vllm_tokens_prompt: false
samples_per_category: 1024
select_only_categories: null
split_by_category: false
truncate: false
prune_args:
n_experts_to_prune: null
overwrite_pruned_model: false
perserve_outliers: false
perserve_super_experts: false
prune_method: reap
reap_args:
debug: false
do_eval: false
plot_clusters: true
profile: false
run_observer_only: false
seed: 42
smoke_test: false
|