The N-Grammer Course
Lessons
- 01CONCEPT5 MIN5 SLIDES2 QUESTIONSWhat is an n-gram?
Bigrams, why counting them predicts the next word, and why N-Grammer uses latent bigrams instead of token bigrams.
- 02CONCEPT6 MIN5 SLIDES2 QUESTIONSThe N-Grammer layer at a glance
Where an N-Grammer layer sits in a transformer, the six steps of its forward pass, and what is learned versus computed.
- 03MATH7 MIN7 SLIDES3 QUESTIONSSnapping to centroids: product quantization
Split a vector into heads, RMS-normalize each slice, and pick the nearest centroid with the |c|² − 2h·c distance trick.
- 04MATH6 MIN6 SLIDES3 QUESTIONSBigram ids and the embedding table
How (previous id, id) pairs become exact rows in one embedding table, the start-of-sequence row, and how many parameters the table costs.
- 05CODE8 MIN7 SLIDES2 QUESTIONSCoding it: PyTorch to Hyperfield
The N-Grammer forward pass in PyTorch and in Hyperfield (TypeScript, WebGPU/CPU) side by side, an op-by-op mapping, and a live layer that matches PyTorch.
- 06CONCEPT7 MIN8 SLIDES3 QUESTIONSTraining it: centroid loss and zero init
Why the ids get no gradient, how the auxiliary centroid loss trains the codebook, what dead centroids are, and why a fresh layer is a no-op.