Local AI · Google AI Developers Blog & Official Documentation
Gemma 2: Complete Open-Weight Model Guide
Photo: Growtika on Unsplash
Gemma 2 is Google's family of freely downloadable large language models available in 2B, 9B, and 27B parameter sizes. Distilled from Gemini and trained with knowledge distillation, these models deliver competitive performance with models many times their size while running efficiently on consumer hardware. Available under a permissive license and compatible with Ollama, LM Studio, and other local inference tools.
What Is Gemma 2?
Gemma 2 is Google's family of open large language models, offering 2B, 9B, and 27B parameter sizes. These lightweight, state-of-the-art open models deliver the best performance for their size, and even offer competitive alternatives to models that are 2-3 times bigger.
Gemma 2 2B is a compact, open-weights language model developed by Google for resource-constrained edge and mobile deployments, distilled from larger Gemini architectures. Gemma 2 is available under a commercially-friendly Gemma license, giving developers and researchers the ability to share and commercialize their innovations.
Available Sizes and Variants
Gemma 2 is available in 2B, 9B, and 27B parameter sizes. Each size comes in two variants:
- Base Model: Pre-trained, suitable for fine-tuning and research
- Instruction-Tuned (IT): Optimized for conversational tasks and user interactions
Technical Specifications
- Context Length: All models support a sequence length of 8,192 tokens.
- Vocabulary Size: 256,128 tokens (significantly larger than competing models)
- Architecture: Dense transformer with decoder-only design
- Training Data: The 9B model training corpus consisted of 8 trillion tokens, primarily from web documents, code, and mathematical content.
Hardware Requirements
Memory Requirements (Full Precision FP16)
Gemma 2 2B: 5.76 GB VRAM at 1K tokens, 6.16 GB VRAM at 8K tokens. A single RTX 4090 or equivalent handles this comfortably.
Gemma 2 9B: Typically requires 18-20 GB VRAM for full precision. GPUs like NVIDIA A100 40GB or RTX 4090 with 24GB VRAM can fine-tune Gemma 2 2B with reduced batch sizes.
Gemma 2 27B: At full precision (FP16) with 8,192 tokens, requires 61.44 GB VRAM, suitable for 1x NVIDIA A100 80GB, 3x RTX 4090 24GB, or 1x Apple M3 Max 128GB.
Quantization Options
- INT8 Quantization: Reduces memory by half (approximately)
- INT4 Quantization: Further reduces to 1/4 of original size, enables laptop inference
- GGUF Format: Optimized for CPU-based inference with Ollama and similar tools
Gemma 2B at Q4 quantization (approximately 1.4GB) can run on a Raspberry Pi 4 with 4GB RAM, delivering approximately 3-5 tokens per second.
Benchmark Highlights
Gemma 2 models demonstrate exceptional performance relative to their parameter count across multiple evaluation frameworks.
LMSYS Chatbot Arena (Human Evaluation)
Gemma 27B (Elo 1218) ranked higher than Llama 3 70B (Elo 1206), Gemma 9B (Elo 1187) similar as GPT-4-0314 (Elo 1186), Gemma 2.6B (Elo 1126) ranked higher than GPT-3.5-Turbo-0613 (Elo 1116).
Academic Benchmarks
On MMLU benchmark, Gemma 2 2B scores 52.2%, Gemma 2 9B scores 71.3%, and Gemma 2 27B scores 75.2%. Additional scores:
- GSM8K (Math): Gemma 2 9B: 68.6%, Gemma 2 27B: 74.0%
- HumanEval (Code): Gemma 2 9B: 68.2%, Gemma 2 27B: 74.9%
- BBH (Reasoning): Gemma 2 9B: 68.2%, Gemma 2 27B: 74.9%
Key Achievement
The 27B model rapidly ascended the LMSYS Chatbot Arena leaderboard, surpassing even popular models more than twice its size in engaging, real-world conversations, while the Gemma 2 2B model outperforms all GPT-3.5 models on the Chatbot Arena at a size runnable on edge devices.
How to Run It Locally
Using Ollama (Easiest Method)
Gemma 2 is compatible with major AI frameworks including Hugging Face Transformers, JAX, PyTorch, TensorFlow via Keras 3.0, vLLM, Gemma.cpp, Llama.cpp and Ollama.
Installation and Usage:
- Install Ollama from ollama.com
- Run one of these commands:
- 2B Parameters: ollama run gemma2:2b
- 9B Parameters: ollama run gemma2
- 27B Parameters: ollama run gemma2:27b
Alternative Tools
Other popular local inference platforms also support Gemma 2:
- LM Studio: Download from lmstudio.ai, provides GUI for model management
- Jan: Open-source alternative with similar functionality
- GPT4All: Beginner-friendly interface with pre-configured models
- Msty: Cross-platform desktop application for local LLM inference
All of these tools allow you to download quantized versions of Gemma 2 from their built-in model catalogs and run them offline.
Best Use Cases
Gemma 2 9B is suitable for content creation such as poetry, copywriting, and code generation, with instruction-tuned variants particularly effective for conversational agents and chatbots, supporting tasks like question answering and summarization.
Ideal Applications:
- Edge Devices & Mobile: The 2B model runs efficiently on phones and embedded systems
- Code Generation & Assistance: Strong performance on HumanEval and coding benchmarks
- Document Summarization: High-quality abstractive and extractive summarization
- Customer Service Chatbots: Instruction-tuned variants excel at user-facing dialogue
- Local Privacy-First Deployments: Full data control with no external API calls
- Educational Tools: Teacher/student Q-A systems and tutoring applications
- Cost-Effective Inference: Single GPU or CPU deployment reduces operational costs
FAQ
Can Gemma 2 run entirely on my laptop without a GPU?
Gemma 2's relatively small size makes it possible to deploy them in environments with limited resources such as a laptop, desktop or your own cloud infrastructure. The 2B model can run on CPU, though speeds will be slow (a few tokens per second). Quantization to INT4 format further reduces memory requirements.
What is the difference between Gemma 2 base and instruction-tuned models?
Base models are pre-trained and optimized for fine-tuning on custom tasks. Instruction-tuned (IT) variants undergo additional training to follow user instructions and engage in dialogue, making them ready to use immediately as chatbots without further training.
Is Gemma 2 truly open-source?
Gemma models are "open-weight" rather than fully open-source - the weights are freely available but the training data and code are not. The permissive license still allows commercial use and redistribution of the model weights.
How does Gemma 2 compare to Llama 3?
The 9B Gemma 2 model delivers class-leading performance, outperforming Llama 3 8B and other open models in its size category. The 27B variant achieves competitive performance with much larger Llama 3 models despite being smaller.
Sources & credits
Original source: Google AI Developers Blog & Official Documentation