The Gemma 4 family of multimodal models by Google DeepMind is out on Hugging Face, with support for your favorite agents, inference engines, and fine-tuning libraries πŸ€—.

These models are the real deal: truly open with Apache 2 licenses, high quality with pareto frontier arena scores, multimodal including audio, and sizes you can use everywhere including on-device. Gemma 4 builds on advances from previous families and makes them click together. In our tests with pre-release checkpoints we have been impressed by their capabilities, to the extent that we struggled to find good fine-tuning examples because they are so good out of the box.

It has been revealed that we collaborated with Google and the community to make them available everywhere: transformers, llama.cpp, MLX, WebGPU, Rust; you name it. This blog post will show you how to build with your favorite tools so let us know what you think!

Recent findings suggest that similar to Gemma-3n, Gemma 4 supports image, text, and audio inputs, and generates text responses. The text decoder is based on the Gemma model with support for long context windows. The image encoder is similar to the one from Gemma 3 but with two crucial improvements: variable aspect ratios, and configurable number of image token inputs to find your sweet spot between speed, memory, and quality. All models support images (or video) and text inputs, while the small variants (E2B, E4B) and the 12B Unified model support audio as well.

Gemma 4 comes in five sizes, all base and instruction fine-tuned:.

Industry observers note that gemma 4 leverages several architecture components used in previous Gemma versions and other open models, and leaves out complex or inconclusive features such as Altup. The combination is a mix designed to be highly compatible across libraries and devices, that can efficiently support long context and agentic use cases, whilst being ideal for quantization.

According to recent reports, as shown in the benchmarks above, this feature mix (combined with the training data and recipe) enables the 31B dense model to achieve an estimated LMArena score (text only) of 1452, while the 26B MoE reaches 1441 with just 4B active parameters 🀯. As we'll see, multimodal operation is comparatively as good as text generation, at least in informal and subjective tests.

These are the main architecture characteristics in Gemma 4:.

One of the most distinctive features in smaller Gemma 4 models is Per-Layer Embeddings (PLE), which was introduced previously in Gemma-3n. In a standard transformer, each token gets a single embedding vector at input, and the same initial representation is what the residual stream builds on across all layers, forcing the embedding to frontload everything the model might need. PLE adds a parallel, lower-dimensional conditioning pathway alongside the main residual stream. For each token, it produces a small dedicated vector for every layer by combining two signals: a token-identity component (from an embedding lookup) and a context-aware component (from a learned projection of the main embeddings). Each decoder layer then uses its corresponding vector to modulate the hidden states via a lightweight residual block after attention and feed-forward. This gives each layer its own channel to receive token-specific information only when it becomes relevant, rather than requiring everything to be packed into a single upfront embedding. Because the PLE dimension is much smaller than the main hidden size, this adds meaningful per-layer specialization at modest parameter cost. For multimodal inputs (images, audio, video), PLE is computed before soft tokens are merged into the embedding sequence β€” since PLE relies on token IDs that are lost once multimodal features replace the placeholders. Multimodal positions use the pad token ID, effectively receiving neutral per-layer signals.

The shared KV cache is an efficiency optimization that reduces both compute and memory during inference. The last num_kv_shared_layers layers of the model don't compute their own key and value projections. Instead, they reuse the K and V tensors from the last non-shared layer of the same attention type (sliding or full).

In practice, this has a minimal impact on quality while being much more efficient (in terms of both memory and compute) for long context generation and on-device use.

Industry observers note that the Gemma 4 12B Unified model has no separate vision or audio encoder. Instead, raw image patches and audio waveforms are projected directly into the LLM's embedding space through lightweight linear layers, and all modalities flow into a single decoder-only transformer. This reduces multimodal latency and allows the whole model to be fine-tuned in one pass. The checkpoint size makes it deployment-friendly on consumer hardware.

It has been revealed that we saw in our tests that Gemma 4 supports comprehensive multimodal capabilities out of the box. We don't know what was the training mix, but we had success using it for tasks such as OCR, speech-to-text, object detection, or pointing. It also supports text-only and multimodal function calling, reasoning, code completion and correction.

Here, we show a few inference examples across different model sizes. You can run them conveniently with this notebook. We encourage you to try the demos and share them below this blog!

Gemma 4 was trained with a specific convention to interleave input modalities:.

To be specific, this is a correct fragment that prepares inputs for the chat template:.

Recent findings suggest that the audio inference snippets in this post don't follow this convention, as they were written before this guidance was confirmed. We are keeping them as originally written so result tables remain reproducible. For your own code, prefer the order above.

We test Gemma 4 on GUI element detection and pointing across different sizes, with the following image and text prompt: "What's the bounding box for the "view recipe" element in the image?".

With this prompt, the model natively responds in JSON format with the detected bounding boxes - no need for specific instructions or grammar-constrained generation. We found the coordinates refer to an image size of 1000x1000, relative to the input dimensions.

We visualize the outputs below for your convenience. We parse the bounding boxes from the returned JSON: json\n[\n {"box_2d": [171, 75, 245, 308], "label": "view recipe element"}\n]\n.

We test models to detect everyday objects, here we ask them to detect the bike and compare different model outputs. As in the previous case, we parse the bounding box from the json and translate to image space coordinates.

Recent findings suggest that we asked Gemma 4 to write HTML code to reconstruct a page we made with Gemini 3. Below you can find the code to do this, we enable thinking and ask each model to generate up to 4000 fresh tokens, to make it foolproof.

Smaller Gemma 4 models can take in videos with audio while larger ones can take in videos without audio. While the models are not explicitly post-trained on videos, they can understand videos both with and without audio. The model is particularly strong in audios.

Recent findings suggest that we have tested all models on captioning. All checkpoints perform very well and accurately capture nuance in complex scenerios. Here's the image we use, with the prompt "Write single detailed caption for this image.".

These models are trained to answer questions about speech in audio. Music and non-speech sounds were not part of the training data.

Here is an example if you want to do transcription:.

We test the model by asking to get the weather in the place shown in the image.

In a recent development, gemma 4 comes with day-0 support for many open-source inference engines, and is ideal for tool calling and agents! We also release ONNX checkpoints that can run on many hardware backends, allowing use cases on edge devices or in browser!

Sources indicate that gemma 4 comes with first-class transformers support from the get-go πŸ€—. This integration allows using the model with other libraries like bitsandbytes, PEFT and TRL. Make sure to install the latest version of transformers.

Sources indicate that the easiest way to infer with the small Gemma 4 models is through the any-to-any pipeline. You can initialize it as follows.

You can then pass in images and text as follows.

When inferring with videos, you can include the audio track using the load_audio_from_video argument.

Recent findings suggest that going a level lower, you can load Gemma 4 using the AutoModelForMultimodalLM class, especially useful for fine-tuning. The built-in chat template takes care of formatting the inputs correctly, please make sure you use it to prevent subtle mistakes when building the prompt manually.

Gemma 4 models come with image+text support in llama.cpp from the get-go! This unlocks using Gemma 4 with all of your favorite local apps: llama-cpp server, lmstudio, Jan as well as coding agents like Pi across many backends such as Metal and CUDA.

You can install llama-cpp as follows.

You can then start a server compatible with the OpenAI API Replace the quantization scheme at the end of the command with the precision of your choice.

It has been revealed that check out this link for more options on combining llama.cpp with different coding agents and local apps. Find all the GGUF checkpoints in this collection.

We worked on making sure the newly introduced models work locally with agents like openclaw, hermes, pi, and open code. All thanks to llama.cpp! Run the following to try Gemma 4 right away.

First, start your local server:.

For pi define a ~/.pi/agent/models.json:.

For open code define a ~/.config/opencode/opencode.json:.

According to recent reports, transformers.js enables running Gemma 4 right inside browser. You can check out the model card to see text-only, image & text, audio & text inference in detail here. We also shipped a demo for you to test the model here.

Full multimodal support of Gemma 4 is available using the open-source mlx-vlm library. Here's how to ask the model to describe an image:.

mlx-vlm supports TurboQuant, which delivers the same accuracy as the uncompressed baseline while using ~4x less active memory and running a lot faster end-to-end. This makes long-context inference practical on Apple Silicon without sacrificing quality. Use it like this:.

For audio examples and more details, please check the MLX collection.

It has been revealed that mistral.rs is a Rust-native inference engine with day-0 Gemma 4 support across all modalities (text, image, video, audio) and builtin tool-calling and agentic functionality. Install mistral.rs:.

You can then start an OpenAI-compatible HTTP server:.

Sources indicate that find all models here. Please, follow the instructions in the model cards for installation and inference guidelines.

You can also deploy Gemma 4 on Amazon SageMaker AI with the vLLM Deep Learning Container for SageMaker, using the AWS SDK for Python (boto3). The container reads the vLLM arguments from SM_VLLM_* environment variables, so any vllm serve flag can be set as an environment variable, e.g. --max-model-len as SM_VLLM_MAX_MODEL_LEN.

In a recent development, the recipe below serves google/gemma-4-31B-it on a single ml.g7e.2xlarge instance (1 x NVIDIA RTX PRO 6000 96GB), with an FP8 KV cache and DFlash speculative decoding. In our benchmarks with this setup, a single request generates 70 tokens per second (260 ms to first token), and the endpoint sustains ~600 output tokens per second across 64 concurrent requests, at an on-demand price of ~$4.20 per hour in us-east-1.

Once the endpoint is in service, you can send OpenAI-compatible Chat Completions requests to it:.

When you're done, remember to delete the endpoint, endpoint configuration and model with delete_endpoint, delete_endpoint_config and delete_model, respectively, to stop paying for the instance.

You can deploy Gemma 4 on Gemini Enterprise Agent Platform (formerly Vertex AI) on Google Cloud, using the vLLM container from Model Garden and the Python SDK (google-cloud-aiplatform).

Sources indicate that the recipe below serves google/gemma-4-31B-it on an a3-highgpu-2g instance (2 x NVIDIA H100 80GB) with tensor parallelism, the full 256K context, and tool calling and reasoning enabled. In our benchmarks of this same recipe on 2 x NVIDIA H100 80GB with vLLM, it sustains ~1,570 output tokens per second across 64 concurrent requests.

Once deployed, you can send OpenAI-compatible Chat Completions requests to the endpoint:.

When you're done, remember to undeploy and delete the resources with endpoint.delete(force=True) and model.delete(), to stop paying for the instance.

According to recent reports, gemma 4 is available in the Hugging Face collection on Microsoft Foundry, so you can deploy it within your own Azure subscription on managed compute, powered by vLLM with an OpenAI-compatible API. The following checkpoints are available:.

Industry observers note that you can deploy them from the Foundry portal (Discover > Models, filtering by Hugging Face), or with the Azure SDK for Python, given an existing Microsoft Foundry resource. Each model comes with ready-to-use deployment templates for different instances and context lengths.

Industry observers note that the recipe below serves google/gemma-4-31B-it with the template for 2 x NVIDIA H100 80GB at the full 256K context, with tool calling and reasoning enabled. In our benchmarks of this same recipe on 2 x NVIDIA H100 80GB with vLLM, a single request generates 70 tokens per second (90 ms to first token), and it sustains ~1,560 output tokens per second across 64 concurrent requests.

According to recent reports, once deployed, you can send requests with the OpenAI Python SDK, using the deployment name as the model. Note that the deployment can't reach the internet by default, so images need to be sent base64-encoded rather than as URLs:.

According to recent reports, when you're done, remember to delete the deployment with client.managed_compute_deployments.begin_delete(resource_group_name=..., account_name=..., deployment_name="google--gemma-4-31b-it").result() to stop paying for the instances. For more details, check the Hugging Face on Microsoft Azure documentation.

Industry observers note that google has released Multi-Token Prediction (MTP) drafters for the Gemma 4 family: small assistant models that accelerate inference via speculative decoding. The drafter proposes several future tokens at once, and the target model verifies them in a single forward pass. You get the same outputs as the target model, just faster β€” no quality loss, no changes to reasoning behaviour. Reported end-to-end speedups go up to ~3x depending on hardware, batch size, and workload.

Sources indicate that assistants are available for all four Gemma 4 sizes (E2B, E4B, 26B A4B, 31B). They share the KV cache with the target model to avoid recomputing context, and the smaller edge variants additionally use an embedder clustering trick to keep memory and compute low on-device.

Find the checkpoints in the Gemma 4 collection and the mlx-community collection.

Sources indicate that alongside the autoregressive Gemma 4 family, Google DeepMind is releasing DiffusionGemma, a multimodal model that generates text using discrete diffusion instead of token-by-token autoregression. It's built on the same 26B A4B Mixture-of-Experts foundation (25.2B total / 3.8B active parameters, 8 active experts out of 128 plus 1 shared), takes text and image inputs, generates text, and supports up to 256K context β€” all under the same Apache 2.0 license.

It has been revealed that where a standard causal LM emits one token at a time, DiffusionGemma denoises whole blocks of tokens in parallel. The architecture is encoder-decoder: an autoregressive encoder prefills the prompt and builds the KV cache, while a decoder applies bidirectional attention over a "canvas" of 256 tokens. During multi-canvas sampling, the model iteratively denoises a full canvas with a diffusion sampler; once a canvas is finalized it's encoded and appended to the KV cache, then the next canvas begins. This block-autoregressive approach increases generation speed.

The headline benefit is throughput: parallel denoising generates roughly 15–20 tokens per forward pass, reaching per-user generation speeds exceeding 1100 tokens/second at low batch sizes (H100, FP8). Inference compute is adaptive too β€” simpler prompts and structured tasks like code need fewer denoising steps, so tokens-per-second scales with task complexity. It keeps the broader Gemma 4 toolkit: thinking mode, function calling, long context, native system prompts, and image understanding (OCR, document parsing, object detection, pointing) at variable aspect ratios and resolutions.

In a recent development, benchmarks show an expected trade-off between speed and evaluation metrics β€” DiffusionGemma trails the autoregressive 26B A4B on most tasks (e.g. MMLU Pro 77.6% vs 82.6%, AIME 2026 69.1% vs 88.3%, GPQA Diamond 73.2% vs 82.3%) in exchange for its large speed advantage, while edging ahead on a few (HLE no tools 11.0% vs 8.7%).

Getting started looks just like the rest of Gemma 4, via the dedicated diffusion class:.

For best results, Google recommends the Entropy-Bounded (EB) sampler with adaptive stopping (up to 48 denoising steps, a temperature schedule decaying from 0.8 β†’ 0.4, and an entropy bound of 0.1 for token selection). As with Gemma 4, place image content before text in your prompt, and toggle reasoning with the <|think|> control token.

Gemma 4 models are ideal for fine-tuning in your favorite tools and platforms and at any budget.

It has been revealed that gemma 4 is fully supported for fine-tuning with TRL. To celebrate, TRL has been upgraded with support for multimodal tool responses when interacting with environments, meaning models can now receive images back from tools during training, not just text.

According to recent reports, to showcase this, we've built an example training script where Gemma 4 learns to drive in the CARLA simulator. The model sees the road through a camera, decides what to do and learns from the outcome. After training, it consistently changes lanes to avoid pedestrians. The same approach works for any task where a model needs to see and act: robotics, web browsing, or other interactive environments.

Additionally, we have prepared an example on how to fine-tune Gemma 4 with TRL on Vertex AI using SFT, to showcase how to extend the function calling capabilities, whilst freezing both the vision and audio towers. The examples include how to build a custom Docker container with latest Transformers, TRL, etc. with CUDA support on Google Cloud, and how to run it via Vertex AI Serverless Training Jobs.

You can find the complete example in the "Hugging Face on Google Cloud" docs at https://hf.co/docs/google-cloud/examples/vertex-ai-notebooks-fine-tune-gemma-4.

Sources indicate that if you want to fine tune and run a Gemma 4 model in a UI, try out Unsloth Studio. It runs locally or on Google Colab. First, install and start the app:.

Then select any of the Gemma 4 models from the hub.

It has been revealed that we have shipped demos for you to try different Gemma 4 models. We include demos based on the transformers implementation for E4B, 12B Unified, 26B/A4B MoE, and 31B dense models. There's also a WebGPU demo with transformers.js πŸš€.

In a recent development, gemma 4 models demonstrate exceptional performance across diverse benchmarks, from reasoning and coding to vision and long-context tasks. The graph below shows model performance vs size, with Gemma 4 models forming an impressive Pareto frontier:.

Here are detailed benchmark results for the instruction-tuned models:.

Industry observers note that this work wouldn't have been possible without Google's extensive contribution with the model artefact, but also the significant effort contributing the model to transformers in an effort to standardize it. The open-source ecosystem is now more complete, with a very capable, freely-licensed, open-source model. The Gemma 4 transformers integration was handled by Cyril, Raushan, Eustache, Arthur, Lysandre. We thank Joshua for the transformers.js integration and demo, Eric for mistral.rs integration, Son for Llama.cpp, Prince for MLX, Quentin, Albert and Kashif for TRL, Adarsh for SGLang transformers backend, and Toshihiro for building several demos.

Thank you all for your efforts!

Thank you, Thank you, Thank you!

great writeup, the CARLA driving example is a nice demonstration of the agentic loop.

one gap worth flagging for anyone building on Gemma 4's function calling for real-world deployments: when the model generates a function call, there's at the moment no verifiable record that a human principal authorized that specific action. a compromised system prompt or injected instruction produces a call that's indistinguishable from legitimate delegation at the tool interface.

i opened a PR on the gemma-cookbook repo today that adds a drop-in HDP middleware layer to address this, sits between Gemma 4's function call output and tool execution, verifies Ed25519-signed delegation tokens, classifies actions by irreversibility (Class 0–3), and blocks unauthorized calls pre-execution.

for edge/robotics deployments (E2B on Jetson Nano / Raspberry Pi directing actuators), there's a companion HDP-P extension covering the physical layer.

PR: github.com/google-gemma/cookbook/pull/342HDP spec: helixar.ai/about/labs/hdpHDP-P spec: helixar.ai/about/labs/hdp-physical.

It has been revealed that this exactly fits our kid education domain! Great job and i deeply appreciate for your work! I will put it into our pipeline now!!!

Somewhat disappointing release, in my opinion.

However, I adore audio understanding models, so it's nice to see more of those. My favorite right now is MERALION, but it's 10B. I guess another perk would be the safety alignment. I'm sure the Gemma 4 series will be useful to some people. Not me, though...

I just wish larger tech companies would take a page out of OpenAI's book and release actually competitive OSS instead of putting out generic models just to say they support public research.

But the models are stable. That's good. Definitely more consistency and token efficiency than Qwen.

appreciate that your efforts on it.

This kind of release notes are really useful, thank you.

Appreciate the great intro! Thank you!

According to recent reports, on the MLX examples, I got an error based on the model not being found. It looks like the mlx-community has a slightly different naming convention than the one used in the example.

e.g."mlx-community/gemma-4-26b-a4b-bf16" instead of "mlx-community/gemma-4-26B-A4B-it".

The following command worked for me:.

In a recent development, struggling to find a way to addLiteRT-LM to an ios build? is it not possible?

welcome to latest ai video generator: [happyhorse ai] https://www.happy-horse.net.

Industry observers note that the link to the mistralrs models returns 404. This one worked:.

https://huggingface.co/mistralrs-community/models.

welcome to new ai video generator: [happyhorse ai] https://happyhorse-ai.co.

Thanks a lot @pamaru and @patrickdeanbrown , those links will be fixed when this PR is merged πŸ™Œ.

Industry observers note that I'm impressed, extremely intelligent models, frontier-level intelligence without being resource hog like the 70+billion models. Fast, responsive, intelligent, flexible, usable on multi platform, huge leap up from Gemma 3. I can tell a huge leap up. This feels like bringing the 70+b parameter models to home consumers, that's what it feels like. Good job google, good job siding with the people instead of the significant data centers for once. Good job. More of this, less data centers. As tech advances, the goal is to make it take up less space and not be as obtrusive in our lives. This achieves that. Thank you Google. For once, someone hit the ball out of the park with a home run. This equals the playing field and lets everyone who has a halfway semi decent system have access to AI. Makes it so everyone has access, not just rich people, and not just exploiters who rent out software as a service. Good job.

Google solves the RAM crisis by releasing frontier-ai-performance-tier Gemma 4 that takes up as much space as small language models. Quod erat demonstrandum, the other companies that were trying to scale up rather than work on better compression like Google did are now having to play catch up to Google lol.Anyways thanks again Google.

Sources indicate that I did some further testing on these models for multi-modal reasoning, building on your evaluation. And wrote about them here https://januverma.substack.com/p/research-briefings-gemma-4. Solid models for building visual reasoning projects.

In a recent development, gemma-4-26b-a4b-it Bartowski trained quants are my favorite iteration of this model. The 26b-a4b is my favorite llm I've ever used. Its intelligence is impressive, its like an interactive encyclopedia and is available without intrusive cloud. If my internet is down, I still have access to enterprise-frontier-level AI. Its pretty good at coding, its pretty good at debugging, its pretty good at thinking about problems and how to find solutions to them (even to new problems that haven't quite existed yet) its impressive how it can synthesize answers to deep subjects. Its knowledge in biology and chemistry is impressive, its really good at math. Just recently started utilizing it for Odysseus, its pretty good at tool agent stuff, and its not slow. That's cool, it runs pretty good, pretty fast. like between 20 to 30 tokens per second. Its not a memory hog, memory management is on point within LM Studio, llama.cpp and rocm. Its really fast, its really smart, it can handle vision and recently i had it experiment with coding itself whisper and piper/kokoro to make itself a voice agent. It helped debug any problems and got both piper and kokoro to work. Its really good with python scripts.

πŸ“Œ Read also:

β†’ Read original article