Google releases Gemma 2 2B, ShieldGemma and Gemma Scope
Google added three models to the Gemma 2 family. Gemma 2 2B is a 2.6B-parameter on-device model, ShieldGemma is a set of 2B/9B/27B safety classifiers for filtering LLM inputs and outputs, and Gemma Scope is a suite of sparse autoencoders for interpretability on Gemma 2 2B and 9B. The post includes usage code for Transformers and llama.cpp, the instruct prompt format, and Open LLM Leaderboard and moderation benchmark results. It also shows how to use the 2B model as an assistant for speculative decoding with Gemma 2 27B, recommending assistants 10–100x smaller than the target for up to a 3x speedup without quality loss.
Related posts
- Welcome Gemma - Google’s new open LLM
Hugging Face mediumAdeptGoogle's Gemma open LLM family ships in 2B and 7B sizes, each with base and instruction-tuned variants and an 8K context. On the Open LLM Leaderboard Gemma 7B scores 63.75, comparable to Mistral 7B, while Gemma 2B trails Phi-2. Hugging Face supports it through Transformers 4.38, including bfloat16 inference in about 18 GB, 4-bit loading in about 9 GB, and a ~4x speedup with torch.compile. Other integrations include JAX/Flax weights, Vertex AI/GKE and Inference Endpoints deployment via Text Generation Inference with an OpenAI-compatible Messages API, and a QLoRA fine-tuning recipe with TRL that takes about 9 hours on one A10G.
- Welcome Gemma 2 - Google’s new open LLM
Hugging Face mediumAdeptGemma 2 ships in 9B and 27B sizes (base and instruction-tuned) with an 8K context, trained on 8T and 13T tokens respectively. Architecturally it interleaves 4096-token sliding-window attention with global attention on alternating layers, applies tanh logit soft-capping (50.0 for attention, 30.0 for final logits), pre-trains the 9B via knowledge distillation, uses on-policy distillation in post-training, and merges models with WARP. Practical notes: soft-capping is incompatible with Flash Attention/SDPA, so fine-tune with eager attention, and run the 27B instruct model in bfloat16 because float16 gives erratic output. Covers Transformers usage (about 18 GB for the 9B model, and 4-bit loading of the 27B in about 18 GB), QLoRA fine-tuning with TRL, and TGI deployment.
- Welcome Gemma 3: Google's all new multimodal, multilingual, long context open LLM
Hugging Face mediumAdeptGemma 3 is Google's open-weight model family in 1B, 4B, 12B and 27B sizes, with 128k context (32k for 1B), image input via a SigLIP encoder on the 4B and larger models, and support for 140+ languages. Long context comes from pretraining at 32k and then scaling to 128k with RoPE base frequency raised to 1M. KV cache size is cut by interleaving 5 local sliding-window layers (window 1024) per global layer. Images get bidirectional attention and "pan and scan" cropping, and a 262K-entry SentencePiece tokenizer improves CJK encoding. The 27B IT model scores 1339 Elo on Chatbot Arena, and the post includes inference code for transformers, MLX, llama.cpp and HF Endpoints.
- Welcome PaliGemma 2 – New vision language models by Google
Hugging Face mediumAdeptPaliGemma 2 pairs Google's SigLIP image encoder with Gemma 2 text decoders, shipping pre-trained vision language models at 3B, 10B and 28B parameters, each at 224, 448 and 896 pixel input resolutions, plus 3B and 10B checkpoints fine-tuned on DOCCI for detailed captioning. The DOCCI fine-tunes cut factual errors in captions, with the 10B model scoring 20.3 non-entailment sentences versus 34.3 for the original PaliGemma. The models run in transformers 4.47+ and can be loaded with bitsandbytes quantization: a 3B checkpoint on TextVQA drops only from 60.04% to 58.72% accuracy at 4-bit nf4. LoRA fine-tuning on half the VQAv2 validation split took about 30 minutes on three 80GB A100s.
- Gemma 3n fully available in the open-source ecosystem!
Hugging Face mediumAdeptGemma 3n, Google's natively multimodal on-device model accepting text, image, audio and video, now runs in transformers, timm, MLX, llama.cpp (text only), Transformers.js/ONNX and Ollama. The E2B and E4B variants have 5B and 8B real parameters but need only about 2GB and 3GB of GPU memory. Per-Layer Embeddings offload embeddings to the CPU, and a nested MatFormer design trains E2B as a sub-model of E4B so layers can be mixed and matched to a memory budget. Vision uses a new MobileNet-V5-300 encoder, audio uses a USM-based encoder over 160ms chunks, and code snippets plus free Colab notebooks cover inference and fine-tuning.