Tobias Taulien

Markov Chain Text Generator

Paste any text, train an n-gram model in milliseconds, and generate gibberish-that-almost-makes-sense — the honest ancestor of every LLM.

Runs 100% in your browser — check the network tab

11,259 / 200,000 characters

n = 2

Loose phrases with some real structure.

0.70
0 = always the most likely word1 = matches real frequencies

Training…

Press Generate to see the model produce text.

Hover — or tap on mobile — any generated word to see the context the model used and the candidates it was choosing between.

Under the Hood

This model is a table: “after these words, these words followed, this often.” Generation is repeated dice rolls weighted by that table — pick a starting phrase, roll for what comes next, slide the window forward one word, and repeat.

Large language models run on the same core idea — predict the next token from the context before it — but replace the lookup table with a neural network that generalizes. This table can only ever say what followed a phrase it has already seen; a neural network can make a reasonable guess about a phrase it has never seen verbatim, and it keeps track of a context window of hundreds of thousands of tokens instead of two or three words.

The honest limit: this model cannot generalize at all. It can only remix sequences it was directly trained on. Turn the Memory slider up to 3 and watch it start quoting the source almost word for word — that’s not the model getting smarter, it’s the model running out of room to do anything except copy.

Go deeper

Sampling uses p_i^(1/temperature), renormalized. At temperature 1 that’s just the raw observed frequencies. As temperature drops toward 0, raising each probability to a larger and larger power exaggerates the gap between the best candidate and everything else, until the distribution collapses onto a single token — greedy, deterministic, always the most common continuation for that exact context.

“Unique states” in the stat line is the number of distinct contexts the table has an entry for. Going from order 1 to order 3 grows that number fast (more specific contexts occur less often), which is exactly why higher orders run out of real alternatives and start reciting the source.