Image-Text-to-Text
Transformers
Safetensors
MLX
gemma3n
automatic-speech-recognition
automatic-speech-translation
audio-text-to-text
video-text-to-text
conversational
6-bit
Instructions to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lmstudio-community/gemma-3n-E4B-it-MLX-6bit") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("lmstudio-community/gemma-3n-E4B-it-MLX-6bit") model = AutoModelForImageTextToText.from_pretrained("lmstudio-community/gemma-3n-E4B-it-MLX-6bit") 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]:])) - MLX
How to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit 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("lmstudio-community/gemma-3n-E4B-it-MLX-6bit") config = load_config("lmstudio-community/gemma-3n-E4B-it-MLX-6bit") # 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
- LM Studio
- vLLM
How to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lmstudio-community/gemma-3n-E4B-it-MLX-6bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmstudio-community/gemma-3n-E4B-it-MLX-6bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/lmstudio-community/gemma-3n-E4B-it-MLX-6bit
- SGLang
How to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit 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 "lmstudio-community/gemma-3n-E4B-it-MLX-6bit" \ --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": "lmstudio-community/gemma-3n-E4B-it-MLX-6bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "lmstudio-community/gemma-3n-E4B-it-MLX-6bit" \ --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": "lmstudio-community/gemma-3n-E4B-it-MLX-6bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use lmstudio-community/gemma-3n-E4B-it-MLX-6bit with Docker Model Runner:
docker model run hf.co/lmstudio-community/gemma-3n-E4B-it-MLX-6bit
Add files using upload-large-folder tool
Browse files- config.json +0 -0
- generation_config.json +1 -1
- model-00001-of-00002.safetensors +2 -2
- model-00002-of-00002.safetensors +2 -2
- model.safetensors.index.json +2 -2
- preprocessor_config.json +2 -1
config.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generation_config.json
CHANGED
|
@@ -9,5 +9,5 @@
|
|
| 9 |
"pad_token_id": 0,
|
| 10 |
"top_k": 64,
|
| 11 |
"top_p": 0.95,
|
| 12 |
-
"transformers_version": "4.
|
| 13 |
}
|
|
|
|
| 9 |
"pad_token_id": 0,
|
| 10 |
"top_k": 64,
|
| 11 |
"top_p": 0.95,
|
| 12 |
+
"transformers_version": "4.54.0.dev0"
|
| 13 |
}
|
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:9eb025ff684e25c699d10debfb16114b329b36123e83d5feb8eeb0972f12efb4
|
| 3 |
+
size 3636349298
|
model-00002-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:3479254e3b03bca833c870f2539381051dea90d288af235dc722163a95e18ba0
|
| 3 |
+
size 3901183685
|
model.safetensors.index.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"metadata": {
|
| 3 |
-
"
|
| 4 |
-
"total_size": 15699956256
|
| 5 |
},
|
| 6 |
"weight_map": {
|
| 7 |
"model.audio_tower.conformer.0.attention.attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
|
@@ -1673,6 +1672,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_size": 15699956384
|
|
|
|
| 4 |
},
|
| 5 |
"weight_map": {
|
| 6 |
"model.audio_tower.conformer.0.attention.attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
|
|
|
| 1672 |
"model.vision_tower.timm_model.blocks.3.9.layer_scale.gamma": "model-00001-of-00004.safetensors",
|
| 1673 |
"model.vision_tower.timm_model.blocks.3.9.norm.weight": "model-00001-of-00004.safetensors",
|
| 1674 |
"model.vision_tower.timm_model.conv_stem.bn.weight": "model-00001-of-00004.safetensors",
|
| 1675 |
+
"model.vision_tower.timm_model.conv_stem.conv.bias": "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",
|
preprocessor_config.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
"data_format": "channels_first",
|
| 4 |
"default_to_square": false,
|
| 5 |
"device": null,
|
|
|
|
| 6 |
"dither": 0.0,
|
| 7 |
"do_center_crop": null,
|
| 8 |
"do_convert_rgb": null,
|
|
@@ -40,7 +41,7 @@
|
|
| 40 |
"processor_class": "Gemma3nProcessor",
|
| 41 |
"resample": 2,
|
| 42 |
"rescale_factor": 0.00392156862745098,
|
| 43 |
-
"return_attention_mask":
|
| 44 |
"return_tensors": null,
|
| 45 |
"sampling_rate": 16000,
|
| 46 |
"size": {
|
|
|
|
| 3 |
"data_format": "channels_first",
|
| 4 |
"default_to_square": false,
|
| 5 |
"device": null,
|
| 6 |
+
"disable_grouping": null,
|
| 7 |
"dither": 0.0,
|
| 8 |
"do_center_crop": null,
|
| 9 |
"do_convert_rgb": null,
|
|
|
|
| 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": {
|