CodeGemma 7B: Google's Open Code Model, Run Locally
CodeGemma is a family of code models Google built on Gemma. The 7B comes as a pretrained model for code completion and an instruction-tuned model for chat; ollama pull codegemma:7b downloads the instruction-tuned version 1.1, a 5.0 GB file.
CodeGemma 7B at a glance
codegemma:7b, v1.1), 7B pretrained for completion (codegemma:7b-code), 2B pretrained for fast completion (codegemma:2b)CodeGemma 7B Runs on Your Own Machine
With Ollama, prompts and code stay on your computer; a cloud coding assistant sends them to the provider's servers
What CodeGemma 7B Is
CodeGemma starts from Google's Gemma 7B and continues training on 500 billion tokens of mostly English web documents, mathematics and code, with the 7B mix at 80% code and 20% natural language. The pretrained models are trained for fill-in-the-middle, so an editor can send the code before and after the cursor and get the missing part back; the instruction-tuned 7B is the one to talk to in a chat (CodeGemma report, sections 2.1 and 2.2).
Pick the build by job: codegemma:7b for questions and code generation in a chat, codegemma:7b-code or the smaller codegemma:2b for inline autocomplete. That split follows the intended uses in Google's model card.
What Google Published: HumanEval, MBPP and BabelCode
Pass@1 scores from Table 3 of the CodeGemma technical report (arXiv:2406.11409). They are Google's numbers; this site has not re-run them.
| Model | HumanEval | MBPP |
|---|---|---|
CodeGemma 7B-IT 1.1 (what codegemma:7b pulls) | 60.4% | 55.2% |
| CodeGemma 7B-IT (first release) | 56.1% | 54.2% |
CodeGemma 7B pretrained (codegemma:7b-code) | 44.5% | 56.2% |
| CodeGemma 2B pretrained 1.1 | 37.8% | 49.2% |
| Gemma 7B pretrained (the starting point) | 32.3% | 44.4% |
In other languages (BabelCode-translated HumanEval, report Table 4) the 7B-IT 1.1 scores 54.7% in C#, 54.0% in Python, 50.3% in Java, 48.4% in JavaScript, 47.8% in Kotlin, 46.6% in C++, 37.3% in Rust and 34.2% in Go. All of these are 2024 results.
Memory, File Size and Speed Ceilings
The weights are a 5.0 GB file. On top of that Ollama keeps a key-value cache that grows with the context. Gemma 7B uses full multi-head attention (16 KV heads of 256 dimensions across 28 layers), so each token of context costs about 0.46 MB at 16-bit precision.
| Context | KV cache | Weights + cache |
|---|---|---|
| 2,048 tokens | 0.9 GB | 6.0 GB |
| 4,096 tokens | 1.9 GB | 6.9 GB |
| 8,192 tokens (the maximum) | 3.8 GB | 8.8 GB |
Ollama needs some working memory on top of these figures. In practice an 8 GB graphics card holds the whole model at a 4K context but not at the full 8K, and a machine with 16 GB of RAM can run it on the CPU at any context length.
Speed: every generated token reads the full 5.0 GB of weights, so memory bandwidth sets a ceiling. Bandwidth ÷ 5.01 GB gives about 54 tok/s on an RTX 4060 (272 GB/s, at a 4K context where it fits on the card), 72 tok/s on an RTX 3060 12GB (360 GB/s), 201 tok/s on an RTX 4090 (1,008 GB/s) and 30 tok/s on an Apple M3 Pro (150 GB/s). These are ceilings, not measurements; real generation lands below them.
Setup with Ollama
System Requirements
Install Ollama Runtime
Linux install script shown; macOS and Windows installers are at ollama.com/download
Download CodeGemma 7B
The instruction-tuned version 1.1, a 5.0 GB download
Verify Installation
Test the model with a simple code request
Optional: Pull a Completion Model
For inline autocomplete use a pretrained variant: codegemma:2b (1.6 GB) or codegemma:7b-code (5.0 GB)
Configure IDE Integration
Editor extensions connect to Ollama at http://localhost:11434. The desktop app and the Linux service already run this server; start it by hand only if neither is running
Using CodeGemma from your editor
- • VS Code and JetBrains: the Continue extension can use
codegemma:7bas a chat model andcodegemma:2borcodegemma:7b-codefor autocomplete. Step by step: Continue.dev + Ollama setup guide. - • Calling the API yourself: the pretrained variants expect fill-in-the-middle prompts built from
<|fim_prefix|>,<|fim_suffix|>and<|fim_middle|>(report Table 1); Ollama's library page shows a Python example withcodegemma:2b-code.
Frequently Asked Questions
What makes CodeGemma 7B different from other coding AI models?
It is Gemma 7B with 500 billion further training tokens, 80% of them code, and its pretrained variants were trained for fill-in-the-middle completion. Google reports 60.4% HumanEval for the instruction-tuned v1.1, against 32.3% for the Gemma 7B it started from (CodeGemma report, Table 3).
How much RAM do I need to run CodeGemma 7B effectively?
About 7 GB at a 4K context (5.0 GB of weights plus a 1.9 GB cache) and about 9 GB at its 8K maximum, so 8 GB of free memory is the practical floor and 16 GB of system RAM is comfortable for CPU-only use.
Can CodeGemma help with Android development specifically?
Google evaluated it on Kotlin and Java (BabelCode HumanEval 47.8% and 50.3% for the 7B-IT 1.1), but the report describes a training corpus drawn from public code repositories, not Android-specific data, so treat it as a general code model.
Can I use CodeGemma 7B in commercial work?
The Gemma Terms of Use do not rule out commercial use; their limits are Google's Prohibited Use Policy and the redistribution conditions in section 3.1, and Google claims no rights in the outputs you generate (section 3.3).
What programming languages does CodeGemma 7B support best?
On Google's BabelCode-translated HumanEval the 7B-IT 1.1 does best in C# (54.7%) and Python (54.0%), then Java (50.3%), JavaScript (48.4%), Kotlin (47.8%) and C++ (46.6%), and worst in Rust (37.3%) and Go (34.2%) (CodeGemma report, Table 4).
Can I use CodeGemma 7B offline?
Yes. After ollama pull codegemma:7b the model runs entirely on your machine, so your prompts and code are not sent anywhere.
📚 Resources & Further Reading
🔧 Official Google Resources
- CodeGemma Model Card
Variants, training data and the coding benchmark table
- CodeGemma: Open Code Models Based on Gemma
Google's technical report (arXiv, June 2024)
- Gemma Terms of Use
The licence CodeGemma is released under
- Gemma Prohibited Use Policy
The use restrictions the terms refer to
🔬 Gemma Research and Code
- Gemma: Open Models Based on Gemini Research and Technology
The paper on the base Gemma models
- Gemma PyTorch Implementation
Official PyTorch implementation
- HuggingFace Gemma Guide
Integration with Hugging Face ecosystem
- Gemma GitHub Repository
Official source code and examples
💻 Running It Locally
- CodeGemma in the Ollama Library
Every tag, size and quantisation
- CodeGemma 1.1 7B-IT on Hugging Face
Original weights; you accept Google's terms before downloading
- Continue: Ollama Provider Docs
Connecting a local model to VS Code or JetBrains
- Continue.dev + Ollama Setup Guide
Step-by-step editor setup on this site
Build Real AI on Your Machine
RAG, agents, NLP, vision, and MLOps - chapters across 25 courses that take you from reading about AI to building AI.
Related Guides
Continue your local AI journey with these comprehensive guides
Go from reading about AI to building with AI
25 structured courses. Hands-on projects. Runs on your machine. Start free.

Written by
Barsha Mohapatra
Founder and Editor, Local AI Master · Founder, Little AI Master
Founder of Little AI Master and the editor behind every course and guide on Local AI Master. Years of tutoring students taught her where AI education actually fails.