Open the WaytoAGI knowledge base on Feishu · 100M+ visits, open to everyone →
WaytoAGI

Knowledge Base · Learning paths

How to Locally Deploy Google Gemma with Ollama: Step-by-Step Guide

Google has released Gemma 2B and 7B, lightweight open-source LLMs designed for local deployment. This guide walks you through installing and running Gemma on your own machine using Ollama, including environment setup, performance comparison between the 2B and 7B models, and useful commands.

Google GemmaOllamalocal LLMdeploy GemmaGemma 2B

Translated from Chinese by AI. Spotted an issue? Use the feedback button.

Author:Chaoye

Google has just released a consumer-grade small model called Gemma, available in 2B (2 billion parameters) and 7B (7 billion parameters) versions. Compared to hundred-billion-parameter large models, these small models may not be suitable for solving highly complex tasks. However, from a trend perspective, they represent a template for localizing models to improve basic operational efficiency — similar to the domestically released ChatGLM-6B last year.

The current deployment environment is much more user-friendly than it was a year ago. First, let’s mention Ollama. Ollama is an open-source large language model serving tool that makes it extremely easy to deploy the latest GPT models and use them via an API. It supports hot-loading model files, allowing you to switch between different models without restarting the service. In addition to Gemma, small models like Llama can also be deployed locally.

Environment Setup

First, visit ollama.com, download the program, and install it (supports Windows, Linux, and macOS).

Open the Command Prompt by searching for “cmd”, then enter:

ollama -v

to check the version. After installation, the version should display 0.1.26.

Use cls to clear the screen, then directly enter:

ollama run gemma

to run the model (2B by default). The first run requires downloading the model, which will take some time. If you want to use the 7B version, run:

ollama run gemma:7b

Once completed, you can start chatting directly. After installing both models, you can repeat the above commands to switch between them.

The 2B version responds extremely quickly, but the range of topics it can interact with is limited. I also tested the 7B version — it runs on my 3050 graphics card, but there is noticeable lag. The output quality is significantly higher, but whether using 2B or 7B, the responses for non-English languages are not very stable.

2B Testing

7B Testing

Here are some commonly used internal commands in the model:

/set — Display adjustable settings in the settings interface
/show — Display model information
/load <model> — Load an existing model
/bye — Exit
/? or /help — Display help commands
/? shortcuts — Display help for keyboard shortcuts

There are currently no practical secondary development projects yet. Ideally, if it could replace the API key in Open Interpreter to perform simple computer control tasks (such as opening a browser to search for “xxx”, writing emails, or running programs), and ideally integrated with a speech library (like Whisper), it would be a very cost-effective direction.

Below are two open-source articles by Chaoye:

Chaoye: Deploying Google Gemma Locally
Chaoye: Understanding Algorithms with the 2048 Mini-Game
Chaoye: Machine Learning - Mastering the Backpropagation Algorithm from Scratch