---
title: "Welcome Gemma 2 - Google’s new open LLM"
description: "Gemma 2 ships in 9B and 27B sizes (base and instruction-tuned) with an 8K context, trained on 8T and 13T tokens respectively."
url: "https://swe.quest/articles/welcome-gemma-2-google-s-new-open-llm-cda5c001e5cdbd53"
canonical: "https://huggingface.co/blog/gemma2"
source: "Hugging Face"
published: "2024-06-27"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 11
tags: ["llms","model-training","inference"]
---

# Welcome Gemma 2 - Google’s new open LLM

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-06-27, 11 min read, Deep dive. Original: [https://huggingface.co/blog/gemma2](https://huggingface.co/blog/gemma2)

## Summary

Gemma 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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)

## Prerequisites

- transformer attention
- LLM fine-tuning basics ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Hugging Face Transformers

## Keywords

Gemma 2, Hugging Face Transformers, TRL, QLoRA, sliding window attention, knowledge distillation, WARP, Text Generation Inference

## Related posts

- [Fine-Tuning Gemma Models in Hugging Face](https://swe.quest/articles/fine-tuning-gemma-models-in-hugging-face-d432d00965e71590.md): Hugging Face · 2024-02-23 · Medium · 5 min read · Model training, LLMs, Python
  Gemma 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.
- [Welcome Gemma - Google’s new open LLM](https://swe.quest/articles/welcome-gemma-google-s-new-open-llm-a7d68dd269473a81.md): Hugging Face · 2024-02-21 · Medium · 9 min read · LLMs, Inference & serving, Model training, Python
  Google's Gemma open LLM family ships in 2B and 7B sizes, each with base and instruction-tuned variants and an 8K context.
- [Welcome Gemma 3: Google's all new multimodal, multilingual, long context open LLM](https://swe.quest/articles/welcome-gemma-3-google-s-all-new-multimodal-multilingual-long-context-open-llm-9610089c9e0bc05e.md): Hugging Face · 2025-03-12 · Medium · 13 min read · LLMs, Inference & serving, Computer vision, Python
  Gemma 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.
- [LoRA Explained: Faster, More Efficient Fine-Tuning with Docker](https://swe.quest/articles/lora-explained-faster-more-efficient-fine-tuning-with-docker-c2d6a36ff181eafe.md): Docker · 2025-10-09 · Medium · 8 min read · Model training, LLMs, Privacy
  Gemma 3 270M can be specialized into a compact PII-masking assistant using LoRA, which freezes the base weights and trains only small low-rank adapters, cutting compute and memory needs while avoiding catastrophic forgetting.
- [Welcome PaliGemma 2 – New vision language models by Google](https://swe.quest/articles/welcome-paligemma-2-new-vision-language-models-by-google-24dd8ece5058fbe9.md): Hugging Face · 2024-12-05 · Medium · 9 min read · Computer vision, LLMs, Model training, Inference & serving
  PaliGemma 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
