AI by Hand ✍️

AI by Hand ✍️

Small Language Model

RNNs by Hand, in Excel

Prof. Tom Yeh's avatar
Prof. Tom Yeh
Sep 27, 2026
∙ Paid

Library › RNNs by Hand, in Excel

  1. Recurrence

  2. Size

  3. Outputs

  4. Depth

  5. Seq2Seq

  6. Tokens

  7. Autoregressive

  8. Loss

  9. Small Language Model

This is the last article of the series. It has one example: the small language model from the start of the series, with every piece now in place.

words, d=6, h=6, layers=4, vocab=30, seq=30, softmax, sample, tied

It reads a word, looks up its embedding, and passes it through four stacked layers. Then it scores every word in the vocabulary, samples one, and reads that word next. Thirty steps later, it has written five sentences.

Now you are rewarded with an understanding of everything important to a language model, including:

  • recurrence: the hidden state, and the same weights reused at every step

  • hidden size, input size, and batches

  • several outputs per step, softmax, and many-to-one

  • stacked layers and bidirectional RNNs

  • the encoder, the decoder, and the bottleneck of the context between them

  • tokens, one-hot vectors, embeddings, and tied embeddings

  • argmax and sampling

  • autoregressive generation and prompts

  • loss and its gradients

I stop short of backpropagation through time. I am still in the middle of doing research on how to represent it in Excel.

The download below has the whole language model in Excel, with live calculations.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2026 Tom Yeh · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture