PSPratyush Shivam

Likely

Watch a language model choose its next word.

Likely: Watch a language model choose its next word.

13 / Explainer · free, in your browser

A real language model runs in your browser and shows the odds it gives every next word before it picks one. Turn one dial to bend those odds, or click any word and follow the sentence that was never written. Nothing is mocked and your text never leaves the page.

Model
SmolLM2, 135M
Runs
On your device
Server
None

TypeScript · WebGPU · in-browser inference

01 · How it works

How a word is chosen

The model reads everything written so far and returns one score, a logit, for each of the 49,152 tokens in its vocabulary. The page keeps the 40 highest, which is top-k sampling. The scores become probabilities through a softmax of score divided by temperature. The probabilities are laid end to end from 0 to 1, and a number in that range picks the word whose stretch it lands in. Then it repeats, until a full stop, a line break or 16 tokens.

02 · How it works

Why the draws are fixed

The random draws are fixed by a seed, on purpose. With the draws held still, anything that changes when you move the dial is the dial's doing. A low temperature exaggerates the gaps between scores until the favourite takes everything. A high one shrinks them until long shots get through. The only liberties the page takes are the shortlist of 40, the fixed draws and the rule for where a sentence ends.

03 · How it works

Opening before the model arrives

A first visit opens at once on a recording of the model's real output, and the whole page is 0.26 MB. The recording covers the sentence at all 20 stops of the dial, and at the default setting the road from each of the top seven runner-ups at every word. One press then downloads the live model: 120 MB on WebGPU with 4-bit weights, or 140 MB on WebAssembly with 8-bit weights. Later visits start in about two seconds.

04 · How it works

Why SmolLM2-135M

It is the smallest model I tried that writes sensible English about whatever you type. Two smaller ones, a 15 MB model trained on children's stories and distilgpt2, were tested on the same prompts and fell short. Given the start of a sentence about the capital of France, SmolLM2-135M placed it on the left bank of the Seine. It runs through Transformers.js 4.3 on ONNX Runtime Web, in a worker, so the page stays responsive.

05 · How it works

A tree in a link

Click any word and pick what it could have been, and the model carries on from there. Sentences that share a beginning share nodes in a tree, so rewriting one leaves the others alone. The prompt, the dial and the whole tree are stored in the part of the link after the #. A link is treated as untrusted input: it is validated, size-limited and only ever written to the page as text.

06 · What it teaches

The idea underneath

Likely shows that a language model does not write sentences. It draws one token at a time from a list of odds. Temperature is not creativity: it is a single number that sharpens or flattens those odds. The branching tree shows how one early draw can send the rest of a sentence somewhere entirely different.

How it works, in one picture

How Likely works, a diagram by Pratyush Shivam: step 1, The text: The model reads everything written so far; step 2, Scores: It returns one score for each of the 49,152 tokens in its vocabulary; step 3, Shortlist: The page keeps the 40 highest; step 4, Odds: The scores become probabilities, and one dial, temperature, bends those odds; step 5, The draw: A number from 0 to 1 picks the word whose stretch it lands in. Then it repeats.
How Likely works

The text → Scores → Shortlist → Odds → The draw. Open the picture to read it at full size.

1600 × 1000 · JPEG

Questions about Likely

01

What does temperature do in a language model?

It divides every score before the softmax. A low temperature widens the gaps, so the favourite word wins almost every time. A high temperature narrows them, so unlikely words get through more often. In Likely you can drag it and watch the sentence rewrite.

02

Does Likely send my text anywhere?

No. The model runs in your browser and nothing you type leaves your device. The only downloads are the page itself and, if you go live, the model weights and the ONNX Runtime WebAssembly binary.

03

What is top-k sampling?

Before a word is drawn, the model's scores are cut to the k highest and the rest are dropped. Likely keeps the top 40 of 49,152 tokens, turns those 40 scores into probabilities and draws one.

In numbers

Likely in numbers: Model, SmolLM2, 135M. Likely is a browser project by Pratyush Shivam: Watch a language model choose its next word.
ModelSmolLM2, 135M

Poster

Poster for Likely, a browser project by Pratyush Shivam: Watch a language model choose its next word.
Likely poster

Likely on one sheet: a screen from it, its name and what it is. Free to use in pieces about the project, with a credit to Pratyush Shivam.

1200 × 1500 · JPEGDownload ↓