Instructions to use google/gemma-4-31B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-31B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/gemma-4-31B-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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("google/gemma-4-31B-it") model = AutoModelForMultimodalLM.from_pretrained("google/gemma-4-31B-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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- AMD Developer Cloud
- Local Apps Settings
- vLLM
How to use google/gemma-4-31B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-4-31B-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-4-31B-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-4-31B-it
- SGLang
How to use google/gemma-4-31B-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-4-31B-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-4-31B-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-4-31B-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-4-31B-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-4-31B-it with Docker Model Runner:
docker model run hf.co/google/gemma-4-31B-it
Chat template: an image-only tool result renders its placeholder after the tool block closes
1
#156 opened 5 days ago
by
nootxlm
Add multiloko results
#155 opened 6 days ago
by
XapaJIaMnu
Fix assistant content order before tool calls
#154 opened 16 days ago
by
youmuorz
Add LongShOTBench evaluation results
#153 opened 17 days ago
by
jazeelmohd
Gemma-4 argues about today's real-world date
1
#152 opened 18 days ago
by
mpuk2000
Add IFBench evaluation result
2
#151 opened 20 days ago
by
SaylorTwift
Add Modality Maturity Index results
#150 opened about 1 month ago
by
dieuwkehupkes
IRIS - infinite context coming soon!
#149 opened about 1 month ago
by
projectiris
Drop the trailing space after the last system text part
#148 opened about 1 month ago
by
qgallouedec
Emit an empty thought after a tool response when enable_thinking=false
#147 opened about 2 months ago
by
sunnyshechkaa
Add LEXam-hard evaluation result
#145 opened 2 months ago
by
joelniklaus
meow
#144 opened 3 months ago
by
hannah-eee
Failure to initiate the reasoning process. Happens at 29 000 - 31 000 tokens deep in chat, quite consistently.
6
#143 opened 3 months ago
by
AutisticPancake
Bug report + proposed fix for chat_template.jinja
🔥👍 3
1
#142 opened 4 months ago
by
Khalidnass
fix(chat_template): emit tool_response multimodal placeholders inside the block
#140 opened 4 months ago
by
leeesangwon
Gemma-4-31B-it occasionally emits <turn|> token when served via vLLM, causing failures when using it with GitHub Copilot Custom Model Provider
3
#138 opened 4 months ago
by
aygupt
fix: chat_template, keep tool-call reasoning across later user turns
#137 opened 4 months ago
by
dimondev
When Gemma doesn't have the right tool schema it hallucinates it, create outputs of the fake-calls and use them as memory (WIP)
👀👍 4
2
#136 opened 4 months ago
by
luislozanog86
Chat template issue: extra newline character when rendering thinking?
👍 1
3
#135 opened 4 months ago
by
ggerganov
Just when I spend 2 weeks researching how to improve natively Gemma's tools calls they fix them lol
👍 3
#134 opened 4 months ago
by
Coronelo
Inconsistent Audio Support in Gemma-4-31B-IT: Video Audio Works, Standalone Audio Fails
2
#132 opened 4 months ago
by
08mohit
Raise per-image vision soft-token budget from 280 to 1120
#131 opened 5 months ago
by
lucianommartins
Rename README.md to README.amh
#129 opened 5 months ago
by
goosemaria149
Update README.md
#128 opened 5 months ago
by
Pq234
gemma4-31b
#127 opened 5 months ago
by
Draeson
Add IFStruct v1.0 evaluation result
#125 opened 5 months ago
by
SaylorTwift
Benchmarked on HexGrid Cloud : Gemma-4 31B + vLLM + RTX 6000 PRO : 1168 tokens/sec and still asking for more...
🚀 1
#123 opened 5 months ago
by
hexgridcloud
Interesting work — mobile AI perspective
#122 opened 5 months ago
by
3morixd
Add ask-my-agent bench v2 (Fallback) evaluation results
#121 opened 5 months ago
by
sapbot
Chat template may re-inject prior-turn reasoning during multi-turn tool use → repetition loops
#119 opened 6 months ago
by
ManniX-ITA
Love Gemma 4! A heartfelt plea from an independent developer regarding Antigravity CLI support
👍 7
6
#117 opened 6 months ago
by
walawalajer
Chat template issues with multiple rounds of tool calling
➕ 2
11
#115 opened 6 months ago
by
Kimahriman
Repetition collapse when continuing an assistant turn (`continue_final_message=true`)
#114 opened 6 months ago
by
CalinAstroBeam
OpenCode Edits Fail
#113 opened 6 months ago
by
Rieker
26b (Dense ) + 31b (MoE) <=VS=> 26b (MoE) + 31b (Dense )
🤯 1
5
#111 opened 6 months ago
by
Markobes
Generating pictures with Gemma-4-31B-it (Try not to laugh)
😎👀 3
2
#110 opened 6 months ago
by
Flanua
Support OpenAI-compatible multimodal content part aliases in chat template
#109 opened 6 months ago
by
yasu-oh
For Science (How model Thinking example)
1
#108 opened 6 months ago
by
Flanua
Tokenizer problems, or just quants?
2
#105 opened 7 months ago
by
nesymerp1
Drops in performance randomly VLLM on H200 and B200 with 2 GPUs
#104 opened 7 months ago
by
jtvino
gemma4-31b-it with MTP enabled works on dual DGX SPARKs now
1
#103 opened 7 months ago
by
kenleo
Gemma4 is super slow on vllm docker , max to max 15 token per second only (4 X L4 GPU)
👍 1
1
#102 opened 7 months ago
by
vi-ajayb
This model is so good, but the KV cache ruins it.
1
#100 opened 7 months ago
by
UniversalLove333
Update README.md
#99 opened 7 months ago
by
hectorruiz9
o-O too good to be true
1
#98 opened 7 months ago
by
mekasu
Weird token after underscore `_//`
4
#96 opened 7 months ago
by
yamikumods
CodeGemma 4 collection
➕ 3
2
#95 opened 7 months ago
by
cbrain
{Feature request] Eliminate pre-attention RMSNorm in Gemma 4 via scale invariance + weight folding
👀 1
#93 opened 7 months ago
by
graefics
Reviews of Gemma 4
4
#92 opened 7 months ago
by
Juanoto2012