cd /news/large-language-models/run-gemma-4-on-your-own-machine-and-… · home › topics › large-language-models › article
[ARTICLE · art-178397] src=zyvop.com ↗ pub= topic=large-language-models verified=true sentiment=↑ positive

Run Gemma 4 on Your Own Machine and Build an Offline Notes Assistant

Google released Gemma 4's edge-sized E2B and E4B models under the Apache 2.0 license alongside LiteRT-LM, a runtime that runs them fully offline on a laptop or Raspberry Pi, with the E2B file at about 2.6 GB. Google's published benchmarks show E2B decoding at 42 tokens/s on a MacBook Pro M4 CPU and 160 tokens/s on GPU, versus 8 tokens/s on a Raspberry Pi 5 (16 GB), while E4B drops to 3 tokens/s on the same Pi with a 20.5-second time to first token. The models let users keep meeting notes, journals and contracts on their own hardware, and the guide builds a Python notes assistant that gives the model two tools, list_notes and read_note, to answer questions over a local folder of Markdown files.

key takeaway

Gemma 4 E2B runs offline via LiteRT-LM at 42 tokens/s on a MacBook Pro M4 CPU and 160 tokens/s with --backend=gpu plus --enable-speculative-decoding=true, but only about 8 tokens/s on a Raspberry Pi 5.

by read6 min views2 publishedNov 30, 2026
Run Gemma 4 on Your Own Machine and Build an Offline Notes Assistant
Image: Zyvop (auto-discovered)

Most AI features come with a quiet requirement: your text has to leave your machine. For meeting notes, a journal, or a half-finished contract, that is a bigger ask than it sounds.

Gemma 4's small models remove it. Google ships E2B and E4B as its edge-sized versions, released under the Apache 2.0 license, and a runtime called LiteRT-LM that runs them on a laptop or a Raspberry Pi. The E2B file is about 2.6 GB. Once it's downloaded, nothing needs the network.

Here you'll get the model answering a prompt from the command line, then build a small Python app that answers questions about a folder of your own notes.

What you need #

  • Linux, macOS, or Windows (the Raspberry Pi works too, with a caveat on speed covered below)
  • About 3 GB of free disk space for the E2B model
  • Python and uv for the install commands

Memory use varies a lot between machines. In Google's published numbers, E2B peaks anywhere from roughly 0.7 GB to 3.5 GB depending on the device and backend, while E4B on one Windows laptop's CPU peaked near 9.4 GB. If you're short on RAM, start with E2B.

Try it in one command #

Install the command-line tool, then run the model straight from Hugging Face:

uv tool install litert-lm

litert-lm run \
  --from-huggingface-repo=litert-community/gemma-4-E2B-it-litert-lm \
  gemma-4-E2B-it.litertlm \
  --prompt="What is the capital of France?"

The first run downloads the model, so expect a wait. On Windows, replace the trailing \ with a backtick.

If you have a supported GPU, add --backend=gpu. Google recommends it, along with --enable-speculative-decoding=true (multi-token prediction), for GPU runs.

How fast will it be? #

Google publishes benchmark numbers for each device. They were measured with 1,024 prefill tokens, 256 decode tokens, and a 2,048-token context, so treat them as a ceiling for your own prompts:

Model Device Backend Decode (tokens/s) Time to first token
E2B MacBook Pro M4 CPU 42 1.1 s
E2B MacBook Pro M4 GPU 160 0.1 s
E2B Raspberry Pi 5 (16 GB) CPU 8 7.8 s
E4B MacBook Pro M4 Max CPU 27 3.7 s
E4B MacBook Pro M4 Max GPU 101 0.4 s
E4B Raspberry Pi 5 (16 GB) CPU 3 20.5 s

The Pi rows show the trade-off most clearly. On the same board, E2B decodes at about 8 tokens per second and E4B at about 3, and the wait for the first token grows from under 8 seconds to over 20.

Build the notes assistant #

The idea: give the model two tools, one that lists your notes and one that reads a single note. When you ask a question, the model decides which note to open and answers from its contents.

Set up

pip install litert-lm-api huggingface_hub

hf download litert-community/gemma-4-E2B-it-litert-lm \
  gemma-4-E2B-it.litertlm --local-dir models

mkdir notes

Put a few Markdown files in notes/. Anything works: meeting notes, a reading log, a trip plan.

The code

Save this as notes_assistant.py:

from pathlib import Path

import litert_lm

litert_lm.set_min_log_severity(litert_lm.LogSeverity.ERROR)

MODEL_PATH = "models/gemma-4-E2B-it.litertlm"
NOTES_DIR = Path("notes").resolve()

SYSTEM = (
    "You answer questions about the user's personal notes. "
    "Call list_notes to see which notes exist and read_note to open one. "
    "If the notes don't contain the answer, say so."
)

def list_notes() -> str:
    """Lists the file names of all available notes, one per line."""
    names = sorted(p.name for p in NOTES_DIR.glob("*.md"))
    return "\n".join(names) or "No notes found."

def read_note(name: str) -> str:
    """Reads one note and returns its text.

    Args:
        name: The file name of the note, exactly as returned by list_notes.
    """
    path = (NOTES_DIR / name).resolve()
    if path.parent != NOTES_DIR or path.suffix != ".md" or not path.is_file():
        return "Note not found."
    return path.read_text(encoding="utf-8")[:6000]

with litert_lm.Engine(MODEL_PATH) as engine:
    messages = [litert_lm.Message.system(SYSTEM)]
    with engine.create_conversation(
        messages=messages, tools=[list_notes, read_note]
    ) as conversation:
        while True:
            question = input("\n>>> ").strip()
            if question.lower() in {"exit", "quit"}:
                break
            response = conversation.send_message(question)
            print(response["content"][0]["text"])

Run it with python notes_assistant.py and ask something like "What did I decide about the budget?" the engine takes a few seconds before the prompt appears.

How the tools work

LiteRT-LM builds each tool's schema from the function's docstring and type hints, which is why read_note documents its name argument. When the model decides it needs a note, it emits a tool call, the library runs your Python function, and the result goes back to the model so it can write the answer. You don't write any of that loop.

One consequence is worth a : the arguments come from the model, so they are untrusted input. A model that is confused, or a note that contains instructions aimed at it, could ask for ../../something-private. That's the reason for the path check in read_note. Any tool you add that touches files, a shell, or the network deserves the same treatment.

Make it faster #

The Python API mirrors the CLI flags:

with litert_lm.Engine(
    MODEL_PATH,
    backend=litert_lm.Backend.GPU(),
    enable_speculative_decoding=True,
) as engine:
    ...

Two details from Google's docs. Multi-token prediction is recommended for GPU backends and for E4B on CPU, but on E2B with CPU it should be enabled selectively, since it can slow down open-ended generation. And if you downloaded the model before May 5, 2026, download it again to use speculative decoding.

Limits worth knowing #

  • Context is small by default. The benchmarks use a 2,048-token context, though the model supports up to 32k. A long chat history plus a 6,000-character note can fill the default quickly, so keep notes short or split them.
  • Tool calling is only as reliable as a 2B-class model. Expect the occasional wrong note or a missed tool call, and keep the system prompt short and direct.
  • Bigger Gemma 4 models aren't there yet. The 26B A4B and 31B variants target workstations and consumer GPUs, but Google's LiteRT-LM page says it supports E2B and E4B for now. Check that page for updates.
  • Startup isn't instant. the engine takes several seconds, so build it once and keep it alive rather than starting it per question.

Where to go next #

The same models handle images and audio. The CLI takes --attachment with --vision-backend or --audio-backend, and the Python Engine accepts the same backends. For apps beyond the desktop, LiteRT-LM has guides for Android (Kotlin), iOS (Swift), C++, and the web.

References #

── more in #large-language-models 4 stories · sorted by recency
── more on @google 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/run-gemma-4-on-your-…] indexed:0 read:6min 2026-11-30 · —