Spaces:
Running
Download README.md from stefflastup/gpt2: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/spaces/stefflastup/gpt2/resolve/main/README.md
- Command line
-
hf download hf://spaces/stefflastup/gpt2/README.md
-
curl -L -o README.md https://huggingface.co/spaces/stefflastup/gpt2/resolve/main/README.md
title: GPT-2
emoji: ✍️
colorFrom: gray
colorTo: indigo
sdk: static
app_file: index.html
pinned: false
short_description: GPT-2 completion + next-token probs, in-browser
GPT-2
A demo of openai-community/gpt2 — the original 124M-parameter GPT-2 — running entirely in your browser via transformers.js. No server, no API key, nothing leaves your machine.
Two views of the same model:
- Completion — streams a continuation of your prompt token by token, with temperature / top-p / top-k / repetition-penalty controls.
- Next token — the raw probability distribution GPT-2 assigns to the next token. This is all the model actually computes; generation is just doing it in a loop.
Implementation notes
Weights come from Xenova/gpt2, the ONNX export of
the same checkpoint (the official repo's ONNX files are fp32-only at 655 MB, too heavy for
a browser download). The app picks its runtime at load time:
| Browser | Backend | Precision | Download |
|---|---|---|---|
| WebGPU available | webgpu |
fp16 | 251 MB |
| otherwise | wasm |
int8 | 281 MB |
Cached by the browser after the first run. Prompts are truncated to keep prompt + generation inside GPT-2's 1024-token context window.
Also in this repo
gradio-zerogpu/ holds an equivalent Gradio + ZeroGPU implementation (server-side
PyTorch, streaming, and an MCP server). It isn't what this Space runs — hosting a Gradio
Space requires PRO or an account older than 30 days — but it's ready to deploy as-is:
hf repos create <ns>/gpt2-gpu --type space --space-sdk gradio --flavor zero-a10g --public
hf upload <ns>/gpt2-gpu ./gradio-zerogpu . --repo-type space