Image-Text-to-Text
Transformers
Safetensors
MLX
gemma3n
automatic-speech-recognition
automatic-speech-translation
audio-text-to-text
video-text-to-text
Instructions to use mlx-community/gemma-3n-E4B-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlx-community/gemma-3n-E4B-bf16 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-bf16")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("mlx-community/gemma-3n-E4B-bf16") model = AutoModelForMultimodalLM.from_pretrained("mlx-community/gemma-3n-E4B-bf16", device_map="auto") - MLX
How to use mlx-community/gemma-3n-E4B-bf16 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-bf16") config = load_config("mlx-community/gemma-3n-E4B-bf16") # 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-bf16 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-bf16" # 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-bf16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mlx-community/gemma-3n-E4B-bf16
- SGLang
How to use mlx-community/gemma-3n-E4B-bf16 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-bf16" \ --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-bf16", "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-bf16" \ --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-bf16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mlx-community/gemma-3n-E4B-bf16 with Docker Model Runner:
docker model run hf.co/mlx-community/gemma-3n-E4B-bf16
- Atomic Chat
File size: 1,092 Bytes
d9dd085 9195b7f d9dd085 | 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 | {
"crop_size": null,
"data_format": "channels_first",
"default_to_square": false,
"device": null,
"disable_grouping": null,
"dither": 0.0,
"do_center_crop": null,
"do_convert_rgb": null,
"do_normalize": false,
"do_rescale": true,
"do_resize": true,
"feature_size": 128,
"fft_length": 1024,
"fft_overdrive": true,
"frame_length": 512,
"hop_length": 160,
"image_mean": [
0.5,
0.5,
0.5
],
"image_processor_type": "SiglipImageProcessorFast",
"image_seq_length": 256,
"image_std": [
0.5,
0.5,
0.5
],
"input_data_format": null,
"input_scale_factor": 1.0,
"max_frequency": 7600.0,
"mel_floor": 1e-05,
"min_frequency": 125.0,
"padding_side": "right",
"padding_value": 0.0,
"per_bin_mean": null,
"per_bin_stddev": null,
"preemphasis": 0.97,
"preemphasis_htk_flavor": true,
"processor_class": "Gemma3nProcessor",
"resample": 2,
"rescale_factor": 0.00392156862745098,
"return_attention_mask": true,
"return_tensors": null,
"sampling_rate": 16000,
"size": {
"height": 768,
"width": 768
}
}
|