Image-Text-to-Text
Transformers
Safetensors
English
gemma3n
gemma3
unsloth
gemma
google
conversational
Instructions to use unsloth/gemma-3n-E4B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/gemma-3n-E4B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/gemma-3n-E4B-it") 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("unsloth/gemma-3n-E4B-it") model = AutoModelForMultimodalLM.from_pretrained("unsloth/gemma-3n-E4B-it", 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 unsloth/gemma-3n-E4B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/gemma-3n-E4B-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/gemma-3n-E4B-it", "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/unsloth/gemma-3n-E4B-it
- SGLang
How to use unsloth/gemma-3n-E4B-it 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 "unsloth/gemma-3n-E4B-it" \ --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": "unsloth/gemma-3n-E4B-it", "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 "unsloth/gemma-3n-E4B-it" \ --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": "unsloth/gemma-3n-E4B-it", "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" } } ] } ] }' - Unsloth Studio
How to use unsloth/gemma-3n-E4B-it with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/gemma-3n-E4B-it to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/gemma-3n-E4B-it to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/gemma-3n-E4B-it to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/gemma-3n-E4B-it", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/gemma-3n-E4B-it with Docker Model Runner:
docker model run hf.co/unsloth/gemma-3n-E4B-it
Upload folder using huggingface_hub
Browse files
model-00001-of-00004.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:1af26e1fd61af0dc067252c907bf52900c7cd5864893e29970e6ea87320322a6
|
| 3 |
+
size 3077103824
|
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",
|