Skip to content

About

CPU-only Gemma 3 270M IT text generation with explicit greedy decoding for COMP110.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Gemma 3 270M IT: greedy text generation

One script, one quoted prompt, one printed reply. Each next token is selected explicitly with argmax(). Fixed settings: CPU, float32, at most four Torch threads, a pinned model revision, a KV cache, and a 128-token reply limit.

Setup

Install uv, then run these commands from this directory (the same commands work in PowerShell):

uv sync

uv creates .venv and installs the exact versions in uv.lock. .python-version selects Python 3.12, which uv can download if necessary. The project supports Python 3.12–3.14. CPU-only PyTorch wheels are selected on Windows/Linux; macOS uses its native wheel. No compiler, CUDA installation, or environment activation is needed. Target platforms are Windows/Linux x86-64 and Apple Silicon macOS 14+; native Intel Macs are not supported by these PyTorch pins.

For a first model download, accept access to google/gemma-3-270m-it, then authenticate:

uv run hf auth login

The first generation downloads about 575 MB into this project's .cache/gemma3. Subsequent runs reuse those files. uv sync installs the Python dependencies; it does not download the model weights.

Run

uv run python main.py "Explain a Python for loop in one sentence."

The program accepts exactly one nonempty prompt argument and no flags. It stops at an end token or the fixed reply limit and prints the decoded reply. Model download/load progress may appear on stderr. With cached weights, Hugging Face's standard HF_HUB_OFFLINE=1 environment variable can disable network checks.

Commit pyproject.toml, .python-version, and uv.lock. For a strict check of the recorded dependencies, use uv sync --locked. To intentionally update transitive dependencies within the project's pins, use uv lock --upgrade.

About

CPU-only Gemma 3 270M IT text generation with explicit greedy decoding for COMP110.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages