# Gemma4.java

A fast, dependency-free inference engine for Google's Gemma 4 language models, written in a single pure-Java file with a GGUF parser and a command-line chat interface.

Gemma4.java is a single-file, zero-dependency inference engine for all Gemma 4 model families (E2B, E4B, 31B and the 26B-A4B mixture-of-experts variant), based on the existing llama3.java project. It includes its own GGUF format parser, supports several quantization types, uses Java's Vector API for matrix-vector kernels, and offers GraalVM Native Image support with ahead-of-time model preloading for faster first-token latency.

Models are downloaded from Hugging Face as GGUF files, and the engine can be run through jbang, which needs no manual clone or build, directly as a .java file, or built into a standalone jar with a provided Makefile; GraalVM can compile it to a native binary. It runs with a chat or prompt mode and a flag that controls a reasoning mode.

It requires Java 21 or newer and is released under the Apache-2.0 license.

Website: https://github.com/mukel/gemma4.java
