Image-Text-to-Text
Transformers
Safetensors
gemma3
conversational
Eval Results
text-generation-inference
Instructions to use google/gemma-3-4b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-3-4b-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/gemma-3-4b-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("google/gemma-3-4b-it") model = AutoModelForMultimodalLM.from_pretrained("google/gemma-3-4b-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?"} ] }, ] 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/gemma-3-4b-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-3-4b-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": "google/gemma-3-4b-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/google/gemma-3-4b-it
- SGLang
How to use google/gemma-3-4b-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 "google/gemma-3-4b-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": "google/gemma-3-4b-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 "google/gemma-3-4b-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": "google/gemma-3-4b-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" } } ] } ] }' - Docker Model Runner
How to use google/gemma-3-4b-it with Docker Model Runner:
docker model run hf.co/google/gemma-3-4b-it
Add model-index with comprehensive benchmark evaluations
#78
by davidlms - opened
Added structured evaluation results from README benchmark tables covering 4 categories:
1. Reasoning & Factuality (11 benchmarks):
- HellaSwag: 77.2, BoolQ: 72.3, PIQA: 79.6, SocialIQA: 51.9
- TriviaQA: 65.8, Natural Questions: 20.0
- ARC-c: 56.2, ARC-e: 82.4, WinoGrande: 64.7
- BIG-Bench Hard: 50.9, DROP: 60.1
2. STEM & Code (8 benchmarks):
- MMLU: 59.6, MMLU Pro COT: 29.2, AGIEval: 42.1
- MATH: 24.2, GSM8K: 38.4, GPQA: 15.0
- MBPP: 46.0, HumanEval: 36.0
3. Multilingual (7 benchmarks):
- MGSM: 34.7, Global-MMLU-Lite: 57.0
- WMT24++ (ChrF): 48.4, FloRes: 39.2, XQuAD: 68.0
- ECLeKTic: 11.0, IndicGenBench: 57.2
4. Multimodal (15 benchmarks):
- COCOcap: 102.0, DocVQA: 72.8, InfoVQA: 44.1, MMMU: 39.2
- TextVQA: 58.9, RealWorldQA: 45.5, ReMI: 27.3
- AI2D: 63.2, ChartQA: 63.6, VQAv2: 63.9
- BLINK: 38.0, OKVQA: 51.0, TallyQA: 42.5
- SpatialSense VQA: 50.9, CountBenchQA: 26.1
Total: 41 benchmarks across reasoning, STEM, code, multilingual, and multimodal capabilities.
This enables the model to appear in leaderboards and makes it easier to compare with other models.
Note: Existing PRs (#57, #49, #34) modify README text content. This PR adds structured metadata to the YAML frontmatter and should not conflict.