Welcome Gemma - Google’s new open LLM
Google'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.
Related posts
- 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 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.
- Llama 2 is here - get it on Hugging Face
Hugging Face mediumAdeptMeta's Llama 2 family (7B, 13B, 70B base and RLHF-tuned chat models) is released under a commercially usable license, trained on 40% more tokens than Llama 1 with 4k context and grouped-query attention for the 70B model, and is integrated across the Hugging Face ecosystem. Inference runs through transformers 4.31 or Text Generation Inference and Inference Endpoints, with recommended GPU sizes per model (A10G for 7B, A100 for 13B, 2-4x A100 for 70B). The 7B model can be fine-tuned on a single 16GB T4 using QLoRA and trl's SFTTrainer. The chat prompt format uses [INST] and <<SYS>> delimiters, and prompts must match the training template exactly for system prompts and multi-turn conversations to work.
- 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.
- Fine-Tuning Gemma Models in Hugging Face
Hugging Face mediumAdeptGemma 2B and 7B can be fine-tuned cheaply with LoRA via the Hugging Face PEFT library, loading the base model in 4-bit NF4 with bitsandbytes (QLoRA) so it fits on free Colab GPUs. A worked example adapts all linear projection layers (r=8) and trains with TRL's SFTTrainer on an English quotes dataset, teaching the model to emit a "Quote/Author" format in just 10 steps. For Cloud TPUs, transformers now supports PyTorch/XLA FSDP via SPMD, enabled by adding an fsdp_config that wraps GemmaDecoderLayer with xla_fsdp_v2 and gradient checkpointing.