Image-Text-to-Text
Transformers
Safetensors
MLX
gemma3n
automatic-speech-recognition
automatic-speech-translation
audio-text-to-text
video-text-to-text
5-bit
Instructions to use mlx-community/gemma-3n-E4B-5bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlx-community/gemma-3n-E4B-5bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="mlx-community/gemma-3n-E4B-5bit")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("mlx-community/gemma-3n-E4B-5bit") model = AutoModelForMultimodalLM.from_pretrained("mlx-community/gemma-3n-E4B-5bit", device_map="auto") - MLX
How to use mlx-community/gemma-3n-E4B-5bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("mlx-community/gemma-3n-E4B-5bit") config = load_config("mlx-community/gemma-3n-E4B-5bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use mlx-community/gemma-3n-E4B-5bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/gemma-3n-E4B-5bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/gemma-3n-E4B-5bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mlx-community/gemma-3n-E4B-5bit
- SGLang
How to use mlx-community/gemma-3n-E4B-5bit 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 "mlx-community/gemma-3n-E4B-5bit" \ --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": "mlx-community/gemma-3n-E4B-5bit", "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 "mlx-community/gemma-3n-E4B-5bit" \ --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": "mlx-community/gemma-3n-E4B-5bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mlx-community/gemma-3n-E4B-5bit with Docker Model Runner:
docker model run hf.co/mlx-community/gemma-3n-E4B-5bit
- Atomic Chat
Upload folder using huggingface_hub
Browse files- README.md +1 -1
- config.json +2 -6
- generation_config.json +1 -1
- model-00001-of-00002.safetensors +2 -2
- model.safetensors.index.json +3 -2
- preprocessor_config.json +1 -1
README.md
CHANGED
|
@@ -16,7 +16,7 @@ tags:
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# mlx-community/gemma-3n-E4B-5bit
|
| 19 |
-
This model was converted to MLX format from [`google/gemma-3n-E4B`]() using mlx-vlm version **0.3.
|
| 20 |
Refer to the [original model card](https://huggingface.co/google/gemma-3n-E4B) for more details on the model.
|
| 21 |
## Use with mlx
|
| 22 |
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# mlx-community/gemma-3n-E4B-5bit
|
| 19 |
+
This model was converted to MLX format from [`google/gemma-3n-E4B`]() using mlx-vlm version **0.3.1**.
|
| 20 |
Refer to the [original model card](https://huggingface.co/google/gemma-3n-E4B) for more details on the model.
|
| 21 |
## Use with mlx
|
| 22 |
|
config.json
CHANGED
|
@@ -63,9 +63,7 @@
|
|
| 63 |
"task_specific_params": null,
|
| 64 |
"problem_type": null,
|
| 65 |
"_name_or_path": "",
|
| 66 |
-
"conf_positional_bias_size": 256,
|
| 67 |
"model_type": "gemma3n_audio",
|
| 68 |
-
"sscp_conv_eps": 0.001,
|
| 69 |
"input_feat_size": 128,
|
| 70 |
"hidden_size": 1536,
|
| 71 |
"rms_norm_eps": 1e-06,
|
|
@@ -3994,9 +3992,7 @@
|
|
| 3994 |
"task_specific_params": null,
|
| 3995 |
"problem_type": null,
|
| 3996 |
"_name_or_path": "",
|
| 3997 |
-
"altup_lr_multiplier": 1.0,
|
| 3998 |
"model_type": "gemma3n_text",
|
| 3999 |
-
"query_pre_attn_scalar": 256,
|
| 4000 |
"vocab_size": 262400,
|
| 4001 |
"vocab_size_per_layer_input": 262144,
|
| 4002 |
"max_position_embeddings": 32768,
|
|
@@ -4143,7 +4139,7 @@
|
|
| 4143 |
"top_k": 50,
|
| 4144 |
"top_p": 1.0,
|
| 4145 |
"torchscript": false,
|
| 4146 |
-
"transformers_version": "4.53.
|
| 4147 |
"typical_p": 1.0,
|
| 4148 |
"use_bfloat16": false,
|
| 4149 |
"vision_config": {
|
|
@@ -4205,7 +4201,7 @@
|
|
| 4205 |
"model_type": "gemma3n_vision",
|
| 4206 |
"num_classes": 2,
|
| 4207 |
"initializer_range": 0.02,
|
| 4208 |
-
"do_pooling":
|
| 4209 |
"model_args": null,
|
| 4210 |
"architecture": "mobilenetv5_300m_enc",
|
| 4211 |
"hidden_size": 2048,
|
|
|
|
| 63 |
"task_specific_params": null,
|
| 64 |
"problem_type": null,
|
| 65 |
"_name_or_path": "",
|
|
|
|
| 66 |
"model_type": "gemma3n_audio",
|
|
|
|
| 67 |
"input_feat_size": 128,
|
| 68 |
"hidden_size": 1536,
|
| 69 |
"rms_norm_eps": 1e-06,
|
|
|
|
| 3992 |
"task_specific_params": null,
|
| 3993 |
"problem_type": null,
|
| 3994 |
"_name_or_path": "",
|
|
|
|
| 3995 |
"model_type": "gemma3n_text",
|
|
|
|
| 3996 |
"vocab_size": 262400,
|
| 3997 |
"vocab_size_per_layer_input": 262144,
|
| 3998 |
"max_position_embeddings": 32768,
|
|
|
|
| 4139 |
"top_k": 50,
|
| 4140 |
"top_p": 1.0,
|
| 4141 |
"torchscript": false,
|
| 4142 |
+
"transformers_version": "4.53.2",
|
| 4143 |
"typical_p": 1.0,
|
| 4144 |
"use_bfloat16": false,
|
| 4145 |
"vision_config": {
|
|
|
|
| 4201 |
"model_type": "gemma3n_vision",
|
| 4202 |
"num_classes": 2,
|
| 4203 |
"initializer_range": 0.02,
|
| 4204 |
+
"do_pooling": false,
|
| 4205 |
"model_args": null,
|
| 4206 |
"architecture": "mobilenetv5_300m_enc",
|
| 4207 |
"hidden_size": 2048,
|
generation_config.json
CHANGED
|
@@ -6,5 +6,5 @@
|
|
| 6 |
"pad_token_id": 0,
|
| 7 |
"top_k": 64,
|
| 8 |
"top_p": 0.95,
|
| 9 |
-
"transformers_version": "4.
|
| 10 |
}
|
|
|
|
| 6 |
"pad_token_id": 0,
|
| 7 |
"top_k": 64,
|
| 8 |
"top_p": 0.95,
|
| 9 |
+
"transformers_version": "4.54.0.dev0"
|
| 10 |
}
|
model-00001-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd5a45e0797166a586369e0872343ef62be4d13b86c04177e39fef782473e584
|
| 3 |
+
size 5368397070
|
model.safetensors.index.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"metadata": {
|
| 3 |
-
"total_parameters":
|
| 4 |
-
"total_size":
|
| 5 |
},
|
| 6 |
"weight_map": {
|
| 7 |
"model.audio_tower.conformer.0.attention.attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
|
@@ -1673,6 +1673,7 @@
|
|
| 1673 |
"model.vision_tower.timm_model.blocks.3.9.layer_scale.gamma": "model-00001-of-00004.safetensors",
|
| 1674 |
"model.vision_tower.timm_model.blocks.3.9.norm.weight": "model-00001-of-00004.safetensors",
|
| 1675 |
"model.vision_tower.timm_model.conv_stem.bn.weight": "model-00001-of-00004.safetensors",
|
|
|
|
| 1676 |
"model.vision_tower.timm_model.conv_stem.conv.weight": "model-00001-of-00004.safetensors",
|
| 1677 |
"model.vision_tower.timm_model.msfa.ffn.pw_exp.bn.weight": "model-00001-of-00004.safetensors",
|
| 1678 |
"model.vision_tower.timm_model.msfa.ffn.pw_exp.conv.weight": "model-00001-of-00004.safetensors",
|
|
|
|
| 1 |
{
|
| 2 |
"metadata": {
|
| 3 |
+
"total_parameters": 8387373392,
|
| 4 |
+
"total_size": 15699956384
|
| 5 |
},
|
| 6 |
"weight_map": {
|
| 7 |
"model.audio_tower.conformer.0.attention.attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
|
|
|
| 1673 |
"model.vision_tower.timm_model.blocks.3.9.layer_scale.gamma": "model-00001-of-00004.safetensors",
|
| 1674 |
"model.vision_tower.timm_model.blocks.3.9.norm.weight": "model-00001-of-00004.safetensors",
|
| 1675 |
"model.vision_tower.timm_model.conv_stem.bn.weight": "model-00001-of-00004.safetensors",
|
| 1676 |
+
"model.vision_tower.timm_model.conv_stem.conv.bias": "model-00001-of-00004.safetensors",
|
| 1677 |
"model.vision_tower.timm_model.conv_stem.conv.weight": "model-00001-of-00004.safetensors",
|
| 1678 |
"model.vision_tower.timm_model.msfa.ffn.pw_exp.bn.weight": "model-00001-of-00004.safetensors",
|
| 1679 |
"model.vision_tower.timm_model.msfa.ffn.pw_exp.conv.weight": "model-00001-of-00004.safetensors",
|
preprocessor_config.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
| 41 |
"processor_class": "Gemma3nProcessor",
|
| 42 |
"resample": 2,
|
| 43 |
"rescale_factor": 0.00392156862745098,
|
| 44 |
-
"return_attention_mask":
|
| 45 |
"return_tensors": null,
|
| 46 |
"sampling_rate": 16000,
|
| 47 |
"size": {
|
|
|
|
| 41 |
"processor_class": "Gemma3nProcessor",
|
| 42 |
"resample": 2,
|
| 43 |
"rescale_factor": 0.00392156862745098,
|
| 44 |
+
"return_attention_mask": true,
|
| 45 |
"return_tensors": null,
|
| 46 |
"sampling_rate": 16000,
|
| 47 |
"size": {
|