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
uvfor 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 #
- Google, Gemma 4 on LiteRT-LM : model sizes, license, benchmark tables
- Google, LiteRT-LM CLI :
litert-lm run, GPU, speculative decoding, attachments - Google, LiteRT-LM Python API :
Engine, conversations, tools, backends - Hugging Face,
litert-community/gemma-4-E2B-it-litert-lm: model files, context length, benchmark conditions - Android Developers Blog, Gemma 4: The new standard for local agentic intelligence on Android (April 2, 2026)