Series
LLMs, the whole thing
Working through large language models from the ground up — turning text into tokens, embeddings and the geometry of meaning, the transformer architecture, attention, how these models are trained, and what separates one generation from the next.
11 posts
·
90 min total
·
updated 20 Sep 2026
Part 1
Large Language Models, From the Ground Up - Part I: The Geometry of Meaning
The opening part of a series building LLMs from first principles. We start where every model starts: turning language into vectors and meaning into geometry, with a runnable script and its real numbers.
12 Aug 2026
·
9 min read
·157 views
Part 2
The Transformer Architecture: Encoder versus Decoder
Every modern LLM is a transformer, yet BERT, GPT and T5 behave very differently. The first article in a ground-up series on LLMs: the single distinction — the attention mask — that separates an encoder from a decoder.
12 Aug 2026
·
7 min read
·171 views
Part 3
From Tokens to Token IDs
An LLM never sees your text — it sees integers. Building a tokenizer from a regex and a dictionary, hitting the out-of-vocabulary wall, and why GPT’s byte-pair encoding is the fix that needs no unknown token.
14 Aug 2026
·
8 min read
·149 views
Part 4
The Sliding Window: How One Story Becomes Thousands of Training Examples
I printed my first training batch, saw shape [8, 4], and could not say what the two numbers counted. Untangling it - one short story sliced into 1,286 windows, grabbed 8 at a time - made the whole GPT input pipeline finally go transparent.
16 Aug 2026
·
6 min read
·79 views
Part 5
The Lookup Table That Learns: Token Embeddings and the Order-Blind Trap
The finale of chapter 2: how meaningless token IDs become the tensor attention actually consumes. It comes down to two lookup tables and one addition - a learnable embedding table for meaning, and a second, position-indexed table for order.
16 Aug 2026
·
6 min read
·118 views
Part 6
Self-attention, from scratch: a context vector is a weighted average
The first attention mechanism in Raschka's LLM book, explained the way it finally clicked for me, a Java dev who bounces off dense maths: self-attention is just three operations, a dot product, a softmax, and a weighted average.
18 Aug 2026
·
9 min read
·138 views
Part 7
Trainable self-attention: query, key, value, and a thermostat on the softmax
Section 3.4 of Raschka's book on six tokens with real PyTorch output: three shared learned matrices, eighteen private q/k/v vectors, why d_in is forced, why scores are divided by the square root of d_k, and why 'weights' now means two different things.
3 Sep 2026
·
12 min read
·62 views
Part 8
Causal attention and the two masks: one hides the future, one cuts links on purpose
Section 3.5 of Raschka's book on seven real GPT-2 tokens: why masking after softmax breaks the row sums, why -inf on the scores fixes it in one pass, and how dropout is a second, random mask that doubles its survivors.
7 Sep 2026
·
6 min read
·77 views
Part 9
Multi-head attention, one shape at a time
Part 9 of LLMs, the whole thing: two heads, one token, and the difference between computing attention and organizing its tensors. A concrete PyTorch walkthrough of view, transpose, concatenation and the output projection.
10 Sep 2026
·
5 min read
·67 views
Part 10
Building GPT from Scratch: LayerNorm, GELU, Shortcuts, and the First Generated Token
Chapter 4 is the moment attention becomes a complete GPT. I build the model one inspectable component at a time, count its parameters, and trace the gloriously untrained first token.
13 Sep 2026
·
16 min read
·99 views
Part 11
Training GPT from Scratch: Loss, Learning, and the Next Token
Chapter 5 connects next-token loss to real parameter updates, then separates training from decoding. My notes on batches, perplexity, validation, sampling, checkpoints, and pretrained GPT-2 weights.
20 Sep 2026
·
6 min read
·85 views