Image-Text-to-Text
Transformers
Safetensors
gemma3n
vllm
vision
audio
int4
conversational
compressed-tensors
Instructions to use RedHatAI/gemma-3n-E2B-it-quantized.w4a16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/gemma-3n-E2B-it-quantized.w4a16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="RedHatAI/gemma-3n-E2B-it-quantized.w4a16") 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("RedHatAI/gemma-3n-E2B-it-quantized.w4a16") model = AutoModelForMultimodalLM.from_pretrained("RedHatAI/gemma-3n-E2B-it-quantized.w4a16", 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 RedHatAI/gemma-3n-E2B-it-quantized.w4a16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/gemma-3n-E2B-it-quantized.w4a16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/gemma-3n-E2B-it-quantized.w4a16", "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/RedHatAI/gemma-3n-E2B-it-quantized.w4a16
- SGLang
How to use RedHatAI/gemma-3n-E2B-it-quantized.w4a16 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 "RedHatAI/gemma-3n-E2B-it-quantized.w4a16" \ --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": "RedHatAI/gemma-3n-E2B-it-quantized.w4a16", "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 "RedHatAI/gemma-3n-E2B-it-quantized.w4a16" \ --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": "RedHatAI/gemma-3n-E2B-it-quantized.w4a16", "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 RedHatAI/gemma-3n-E2B-it-quantized.w4a16 with Docker Model Runner:
docker model run hf.co/RedHatAI/gemma-3n-E2B-it-quantized.w4a16
Error RedHatAI/gemma-3n-E2B-it-quantized.w4a16 is not a multimodal model
#1
by mtobing - opened
I ran this model using vllm and when I tried to extract text from an image in Open WebUI, I got this error
ERROR 10-18 19:36:15 [serving_chat.py:208] File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/chat_utils.py", line 553, in mm_processor
ERROR 10-18 19:36:15 [serving_chat.py:208] return self.mm_registry.create_processor(self.model_config)
ERROR 10-18 19:36:15 [serving_chat.py:208] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 10-18 19:36:15 [serving_chat.py:208] File "/usr/local/lib/python3.12/dist-packages/vllm/multimodal/registry.py", line 242, in create_processor
ERROR 10-18 19:36:15 [serving_chat.py:208] raise ValueError(f"{model_config.model} is not a multimodal model")
ERROR 10-18 19:36:15 [serving_chat.py:208] ValueError: RedHatAI/gemma-3n-E2B-it-quantized.w4a16 is not a multimodal model
I saw Input: Audio-Vision-Text for this model.
Is this multimodal? or did i miss something. I ran vllm with this command
python3 -m vllm.entrypoints.openai.api_server
--model RedHatAI/gemma-3n-E2B-it-quantized.w4a16
--trust-remote-code
--limit-mm-per-prompt.image 1
--limit-mm-per-prompt.video 1
--limit-mm-per-prompt.audio 1
--gpu-memory-utilization 0.85
--max-model-len 4K
--max-num-seqs 5
--max-num-batched-tokens 4K
--host 0.0.0.0
--port 8000
--dtype bfloat16
mtobing changed discussion title from Is this multimodal ? to Error RedHatAI/gemma-3n-E2B-it-quantized.w4a16 is not a multimodal model