sweedworks

Source

Every figure on this site is computed by one of these scripts rather than typed in by hand, and every interactive tool is checked against a second implementation before it ships. Here they all are.

Nothing here is compiled or obfuscated. If you want to know how a number on this site was produced, you can read the line that produced it. The JavaScript is served at its own paths — permalink.js, bpe.js, ngram.js, tokens/app.js.

FileWhat it doesLines
build.shThe whole build, every step61
chatcost.pyThe chat billing rule, checked against the encoder116
mlp.pyThe neural language model behind /learn/, by hand311
checkmlp.pyGradient checks, and browser vs Python agreement141
bpe.pyByte pair encoding — the reference for /vocabulary/119
ngram.pyThe n-gram model and sampling knobs behind /predict/175
render.pyGenerates every page on the site, including this one1900
precompute.pyComputes the figures on /tokens/147
precompute_merges.pyComputes the figures on /vocabulary/66
precompute_predict.pyComputes the figures on /predict/80
corpora.pyThe training texts used throughout61
verify.pyChecks both shipped tokenizer bundles against the reference103
makebundle.pyBuilds the cl100k browser bundle upstream got wrong159
checkbpe.pyBrowser BPE trainer vs the Python reference99
checkngram.pyBrowser sampler vs the Python reference158
checkhtml.pyStrict HTML parse, dead links, feed and sitemap156
checkjs.pyCompiles the site's JavaScript with a real engine48
checkpermalink.pyRound-trips shareable links through a stubbed DOM272
checklive.pyCompares served bytes against what was generated136
cjsload.pyLoads the tokenizer's CommonJS build under QuickJS88
tokenlib.pyLoads the shipped browser bundle under QuickJS82
The build runs these in order; it fails and refuses to deploy if any check does not pass.