Instructions to use zeromodels/gemma-4-e2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/gemma-4-e2b with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/gemma-4-e2b") - Keras
How to use zeromodels/gemma-4-e2b with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/gemma-4-e2b") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
b51e234 verified | { | |
| "library_name": "zeromodels", | |
| "zeromodels_version": "1.2.1", | |
| "model_module": "zeromodels.models.gemma4", | |
| "model_class": "Gemma4ConditionalGenerate", | |
| "variant": "gemma-4-e2b", | |
| "weights": "model.weights.json", | |
| "schema_version": 2, | |
| "weight_dtype": "bfloat16", | |
| "model_type": "gemma4", | |
| "text_config": { | |
| "vocab_size": 262144, | |
| "embed_dim": 1536, | |
| "mlp_dim": 6144, | |
| "num_layers": 35, | |
| "num_heads": 8, | |
| "num_kv_heads": 1, | |
| "num_global_kv_heads": 1, | |
| "head_dim": 256, | |
| "global_head_dim": 512, | |
| "k_eq_v": false, | |
| "enable_moe": false, | |
| "num_experts": 0, | |
| "num_experts_per_tok": 0, | |
| "moe_mlp_dim": 0, | |
| "sliding_window": 512, | |
| "sliding_window_pattern": 6, | |
| "layer_types": [ | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "sliding_attention", | |
| "full_attention" | |
| ], | |
| "partial_rotary_factor": 0.25, | |
| "final_logit_softcapping": 30.0, | |
| "norm_eps": 1e-06, | |
| "rope_theta": 1000000.0, | |
| "rope_local_theta": 10000.0, | |
| "tie_embeddings": true, | |
| "hidden_size_per_layer_input": 256, | |
| "vocab_size_per_layer_input": 262144, | |
| "num_kv_shared_layers": 20, | |
| "use_double_wide_mlp": true | |
| }, | |
| "vision_config": { | |
| "hidden_size": 768, | |
| "num_layers": 16, | |
| "num_heads": 12, | |
| "num_kv_heads": 12, | |
| "head_dim": 64, | |
| "intermediate_size": 3072, | |
| "patch_size": 16, | |
| "position_embedding_size": 10240, | |
| "pooling_kernel_size": 3, | |
| "rope_theta": 100.0, | |
| "eps": 1e-06, | |
| "standardize": false, | |
| "use_clipped_linears": true | |
| }, | |
| "audio_config": { | |
| "hidden_size": 1024, | |
| "num_layers": 12, | |
| "num_heads": 8, | |
| "conv_channels": [ | |
| 128, | |
| 32 | |
| ], | |
| "conv_kernel_size": 5, | |
| "chunk_size": 12, | |
| "context_left": 13, | |
| "context_right": 0, | |
| "logit_cap": 50.0, | |
| "invalid_logits": -1000000000.0, | |
| "residual_weight": 0.5, | |
| "norm_eps": 1e-06, | |
| "output_proj_dims": 1536, | |
| "use_clipped_linears": true | |
| }, | |
| "image_token_id": 258880, | |
| "video_token_id": 258884, | |
| "audio_token_id": 258881, | |
| "pad_token_id": 0, | |
| "use_bidirectional_vision": false | |
| } | |