← All models

text-generation Β· tiny story LLM Β· WASM Β· ~15 MB

llama2.c-stories15M β€” the smallest storyteller

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.

At a glance

ModelXenova/llama2.c-stories15M (ONNX) Β· original karpathy/tinyllamas (stories15M)
Tasktext-generation (autoregressive next-token prediction)
ArchitectureLlama β€” 15M-parameter decoder (6 layers, 288 hidden), trained on TinyStories
Params / dtype15M Β· int8 (8-bit quantized ONNX)
BackendWebAssembly (CPU) β€” no GPU required; runs even on modest phones
Download~15 MB β€” the smallest model on the showcase
LicenseMIT
Web APIsWeb Workers, Cache Storage (via Transformers.js), WebAssembly

Run it

The story will stream here.

See inside β€” 15 million parameters at work

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.

Why it matters

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.

Use cases

Basics

Finish the story β€” a classic TinyStories opener, streamed end to end.

Practical

A story factory: pick a character and a problem, get a clean bedtime-story draft with a moral.

Wild

Story remix β€” the same opener, regenerated with different sampling, never twice the same.

How the API works

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.

References