annagram
how it works
what it is
annagram is a tiny character-level language model built on my text: an interpolated Kneser–Ney n-gram model trained on about 37,000 words of my messages to coding agents, my notes, and my blog posts. It runs entirely in your browser, and I’ll add more text as I write it.
how it picks a letter
It writes one character at a time. To pick the next one, it looks at the last 9 characters and counts what I’ve typed after exactly those 9. If I’ve rarely written that stretch, it backs off to the last 8, then 7, and so on, blending the counts so it never runs out of ideas. Gray letters came from a short stretch, solid ones from a familiar one, and pink ones from a stretch I type all the time.
[rand], the space bar, or poking me starts from nothing; type in [given] and it continues from your words.
[show the math][hide the math]
P(c | h) = max(N(hc) − D, 0)N(h) + λ(h) P(c | h′)
- c
- next character
- h
- context: the preceding 9 characters
- h′
- h without its first character (order 8, then 7, … down to uniform)
- N(hc)
- count of hc in the corpus at the top order; at lower orders, the continuation count |{v : N(vhc) > 0}|
- N(h)
- Σc N(hc)
- D
- absolute discount per order, n₁ / (n₁ + 2n₂)
- λ(h)
- backoff weight, D · |{c : N(hc) > 0}| / N(h)
what it leaves out
Before training I scrubbed names, links, and anything personal (the black bars are what got redacted) and pruned long phrases I only wrote once. It also refuses to quote me more than seven words in a row.
top 6 by model probability, before sampling adjustments. Hover over (or tap) a letter to see its context h and its distribution.