Reading nano-ai.tech: Good Technical Explanations Turn Black Boxes into Verifiable Parts
Notes on nano-ai.tech's 'LLM From Scratch' series and interactive Attention lab—how replacement checklists and 3×2 editable matrices make internals concrete.
Finding a Technical Site Worth Reading Cover to Cover
While refining my personal site and technical notes recently, I came across nano-ai.tech.
Most writing on large language models tends to fall into one of two extremes. Either it stops at high-level diagrams and equations—leaving you with the terminology but no feel for how tensor shapes actually change in code—or it dumps hundreds of lines of framework source code where the core invariant gets lost in boilerplate.
Reading through nano-ai.tech—specifically its “LLM From Scratch” series and its interactive “LLM Lab”—what struck me most was its discipline: it consistently turns an intimidating black box into a line-by-line parts list and a table you can verify by hand.
Here are a few things I found worth recording.
1. Hold the Skeleton Constant, Then Hand Over a Parts List
Many explanations of LLaMA open with a laundry list of components: RMSNorm, SwiGLU, RoPE, GQA. You might know what each term means in isolation, yet still feel fuzzy about which exact lines of a forward pass changed compared with GPT-2.
In “From GPT-2 to LLaMA · EP05 | Assembling the Full Model”, the author starts by placing the two core lines of a GPT-2 block right next to a LLaMA block:
# GPT-2 Block
x = x + attn(ln_1(x)) # LayerNorm → MHA (positional embedding added before blocks)
x = x + mlp(ln_2(x)) # LayerNorm → GELU FFN
# LLaMA Block
x = x + attn(norm_1(x)) # RMSNorm → GQA (RoPE rotates q and k inside attention)
x = x + mlp(norm_2(x)) # RMSNorm → SwiGLU
Side by side, the picture clicks immediately:
- The skeleton did not move a single line: both use Pre-LN (normalize before entering the sub-layer), both add the residual connection back to the un-normalized
x, and both alternate attention with a feed-forward network. - What changed are four modular parts hanging off that skeleton:
LayerNormbecomesRMSNorm(dropping mean-centering and bias);- The learned absolute positional table (
wpe) added once at the input is replaced byRoPE, which rotatesqandkinside every attention layer so attention scores depend on relative distance; - Standard Multi-Head Attention (
MHA) becomes Grouped-Query Attention (GQA), where groups of query heads share key/value heads; - The
GELUfeed-forward network becomes gatedSwiGLU.
Once that backbone is clear, the remaining details you hit when loading pretrained weights—setting bias=False on linear projections, removing the fixed-length wpe table, and untying lm_head from the token embedding matrix—fall naturally into place.
The explanation works because it first anchors the invariant (the Pre-LN residual skeleton) before introducing new concepts as localized part swaps.
2. The Interactive Lab: A 3×2 Toy Matrix Beats an Abstract Formula
Another page I spent a long time playing with is the “LLM Lab” (/attention/), which covers Attention, LayerNorm, ReLU / GELU, and MLA.
Everyone can recite $\text{Attention}(Q, K, V) = \text{softmax}(QK^T / \sqrt{d_k})V$. Yet when debugging an implementation, two practical questions still trip people up:
- Where exactly does the causal mask happen—and why must it be applied after scaling by $\sqrt{d_k}$ but before Softmax?
- What does numerically stable Softmax (subtracting the row maximum before exponentiating) change, and what does it leave invariant?
Instead of a flashy 3D animation you can only watch passively, nano-ai.tech/attention/ gives you three editable $3 \times 2$ toy matrices (Q, K, V) for 3 tokens with $d_k = 2$:
- You can edit any cell directly or toggle the causal mask checkbox;
- Right next to it, all four intermediate steps update live:
- Similarity scores: dot products scaled by $\sqrt{2}$ to form the $3 \times 3$ score matrix $S$;
- Causal mask: future positions masked before normalization;
- Stable Softmax: subtracting each row’s maximum before
expand normalization to produce the attention weight matrix $A$; - Weighted sum: clicking
q1,q2, orq3breaks down exactly how that query row’s weights multiply $V_1, V_2, V_3$ and sum to the output row $O$.
“The toy matrices are for demonstrating the calculation only; they do not represent a trained model or semantic meaning.”
That disclaimer at the top of the page is refreshingly honest. It never pretends a $3 \times 2$ matrix captures language semantics—instead, it makes every intermediate number in matrix multiplication, scaling, masking, and normalization something you can poke at and verify with mental arithmetic.
3. What I Want to Carry into My Own Work
Why did this resonate with me so strongly? Because it mirrors the exact problem I care about when building agent systems and designing this site.
Whether I am writing the hand-rolled tool loop for my AI News Agent or defining what counts as a good-enough incident diagnosis for AgentOps, I keep coming back to the same observation: what makes a system hard to trust is rarely its input or its final output—it is the hidden intermediate steps in between.
- When learning model internals, if you only see input tokens and output logits, RoPE rotations and GQA head sharing remain opaque; laying out a $3 \times 2$ matrix and a side-by-side block diff makes the mechanism inspectable.
- When building AI agents, if you only see the user prompt and the final markdown brief, the distinction between a model reply round and multiple tool calls, evidence-ID validation, and budget exhaustion remains opaque; turning the run trace into an interactive timeline you can scrub through step by step makes the boundaries concrete.
Break complex systems into small, verifiable parts; don’t skip steps; and make intermediate states directly inspectable. That is what nano-ai.tech does remarkably well—and it is the standard I want to hold my own writing and engineering to.