text-generation Β· tiny story LLM Β· WASM Β· ~15 MB
This is a 15-million-parameter Llama, trained from scratch by Karpathy's llama2.c project on TinyStories β a dataset of short, simple tales written for 3β4 year olds. Fifteen megabytes of weights, yet it learned grammar, plot, and a happy ending. Give it an opener and watch it write, token by token, on your device.
| Model | Xenova/llama2.c-stories15M (ONNX) Β· original karpathy/tinyllamas (stories15M) |
|---|---|
| Task | text-generation (autoregressive next-token prediction) |
| Architecture | Llama β 15M-parameter decoder (6 layers, 288 hidden), trained on TinyStories |
| Params / dtype | 15M Β· int8 (8-bit quantized ONNX) |
| Backend | WebAssembly (CPU) β no GPU required; runs even on modest phones |
| Download | ~15 MB β the smallest model on the showcase |
| License | MIT |
| Web APIs | Web Workers, Cache Storage (via Transformers.js), WebAssembly |
Each chip below is a decoded text chunk from this tiny Llama on your CPU, not necessarily one token. The readout counts generated token IDs (including special tokens, excluding the prompt); average tok/s includes prefill and generation. Compare it with the other language models on this showcase: 15M parameters is roughly a thousandth of a modern LLM. What this model does with so little β grammar, characters, a beginning-middle-end β is what the TinyStories paper demonstrated: with simple, well-formed text, even small models learn narrative structure.
the decoded text stream
The TinyStories line of work β and llama2.c β proved that scale isn't the only path to competence: a 15M model trained on a small, clean, constrained corpus can write coherent, grammatical stories. For the web, that means a language model that downloads in a second and runs on a five-year-old phone.
The friendly one-liner is the text-generation pipeline:
import { pipeline } from "@huggingface/transformers";
const gen = await pipeline("text-generation", "Xenova/llama2.c-stories15M", { dtype: "int8" });
const out = await gen("Once upon a time, there was a little fox named Fred who", {
max_new_tokens: 90, do_sample: true, temperature: 0.8,
});
// out[0].generated_text β the opener plus a short children's story
The demo streams tokens through a TextStreamer inside a Web Worker, so the page never
blocks β the chips above show decoded text chunks as words become available.