You’ll learn why a Feed-Forward Network (FFN) is needed after attention, and how attention, FFNs, residual connections, and layer normalization form one reusable transformer block. You’ll also compare encoder-decoder, encoder-only, and decoder-only transformers, including why attention’s O(n2) cost limits sequence length.
Attention Can Gather, But Not Think
Attention has just run on “The cat sat.” The word “sat” now carries blended context from “The” and “cat.” It knows the subject is a cat and the sentence is past tense. But what can it do with that knowledge?
If we skip straight from attention to the output layer, the model can only produce weighted combinations of existing token representations. It can copy and blend, but it can’t compute anything new. It couldn’t combine “subject is singular” + “verb should agree” into a grammatical prediction. It couldn’t learn “after [animal] [past-tense verb], predict a location.” It needs a processing step.
That processing step is the Feed-Forward Network: per-token computation that transforms gathered context into useful features.
Attention = “gather information from other tokens” (communication)
FFN = “think about what you’ve gathered” (computation)
Step through the animation to see how the FFN processes a single token’s vector:
Input
dmodel
0.5
-0.3
0.8
1.2
-0.1
0.4
-0.6
0.9
× W1
8 → 32
Hidden
dff = 4×
ReLU17/32 zeroed
× W2
32 → 8
Output
dmodel
3.2
3.2
-2.7
-4.1
1.5
0.2
-1.2
-2.5
input
One token's vector. Each bar is one dimension: 8 shown, hundreds or thousands in a real model.
What to look for: The vector expands to 4x its size, giving ReLU room to create sparse activation patterns (about half the neurons fire). Then it contracts back to the original size. Same shape in, same shape out, but the values have been transformed.
The FFN applies two linear transformations with ReLU in between. ReLU is the simplest non-linear activation: negative values become 0, positive values pass through unchanged.
Why expand then contract? ReLU makes a binary decision on each dimension: keep (positive) or kill (zero). Each dimension is one yes/no question about the input. With only 512 dimensions, you get 512 questions. With 2048 dimensions, you get 2048 questions. More questions means finer-grained analysis, the same reason 20 Questions works better than 5 Questions. (Unlike 20 Questions, the FFN’s “questions” aren’t sequential or adaptive: all 2048 ReLU decisions happen simultaneously and independently, without building on each other’s answers.)
Here’s a tiny worked example. Say the input is [1.0, -0.5] and we expand to 4 dims:
A different input, say [-0.5, 1.0], would trigger different neurons to fire, producing a completely different pattern. With 4 neurons, there are up to 24=16 possible on/off combinations, so the network can treat up to 16 different input regions differently. With only 2 neurons (no expansion), you’d get just 22=4 regions. In the real model: 22048 possible patterns vs 2512 without expansion. Exponentially more expressive.
Why contract back? The expansion is temporary scratch space. The rest of the model (attention in the next block, the output layer) expects 512-dim vectors. The contraction reads the ReLU activation pattern and writes a 512-dim summary of what was detected.
FFN(x)=ReLU(xW1+b1)W2+b2
Where:
x: input vector (output from attention sub-layer)
W1, b1: weights and bias for the “expand” step (shape: dmodel→dff)
W2, b2: weights and bias for the “contract” step (shape: dff→dmodel)
ReLU(x)=max(0,x): zero out negatives, keep positives
The FFN has more parameters than the attention layers in each block: roughly twice as many. Most of a transformer’s weights live in FFN layers, not attention. (Here, dmodel is the vector size that flows through the entire transformer: 512 in the original paper, 8 in our toy model. dff is the expanded FFN width, typically 4×dmodel.)
Multi-Head Attention has 4 weight matrices, each dmodel×dmodel:
Matrix
Role
Shape
WQ
Project to queries
512 x 512
WK
Project to keys
512 x 512
WV
Project to values
512 x 512
WO
Combine head outputs
512 x 512
Total: 4×5122 = 1.05M parameters
Feed-Forward Network has 2 weight matrices:
Matrix
Role
Shape
W1
Expand
512 x 2048
W2
Contract
2048 x 512
Total: 2×512×2048 = 2.10M parameters
The FFN uses roughly twice the parameters of attention per block.
🤔Quick Check
Why does the FFN expand the dimension to 4x before contracting back?
Your turn
Choose an answer to check your understanding.
Try another option
Think about what ReLU does with more dimensions to work with...
Correct!
The wider hidden layer (4x expansion) gives ReLU a larger space to carve out complex feature patterns. Different neurons fire for different feature combinations, and the contraction keeps only what matters.
Answer: B
The wider hidden layer (4x expansion) gives ReLU a larger space to carve out complex feature patterns. Different neurons fire for different feature combinations, and the contraction keeps only what matters.
Modern transformers replace ReLU with SwiGLU, a gated activation:
SwiGLU(x)=(Swish(xW1)⊙xV)W2
Where Swish(x)=x⋅σ(x) and ⊙ is element-wise multiplication.
This adds a “gate” (the V projection) that controls which features pass through. It consistently outperforms ReLU with only a small parameter increase.
GeGLU (Used in some models)
GeGLU(x)=(GELU(xW1)⊙xV)W2
Same idea but with GELU activation instead of Swish.
Anatomy of a Transformer Block
Now we have both pieces: attention for communication and FFN for computation. But stacking them naively fails. Each sub-layer completely overwrites its input: the attention output replaces the original token vector, then the FFN output replaces that. After 96 blocks, nothing remains of the original signal. Gradients face the same problem in reverse: they must pass through every transformation, shrinking toward zero. Two helpers fix this:
Residual connection: add the sub-layer’s input back to its output (x+sublayer(x)). The original signal always passes through, even if the sub-layer learns nothing useful. Gradients get a clean shortcut that bypasses the transformation entirely. (Forgot why? Review residual connections.)
Layer normalization: normalize the vector to mean ≈ 0 and std ≈ 1, preventing activations from drifting or exploding across layers. (Forgot why? Review LayerNorm.)
Where you place LayerNorm matters. The original 2017 paper put it after the residual add (Post-LN). This worked for 6 layers, but when researchers tried stacking to 96, training became unstable: gradients had to pass through LayerNorm at every layer on the residual path, and the repeated scaling caused them to vanish. The fix was simple: move LayerNorm before the sub-layer (Pre-LN), so the residual path stays a clean identity with nothing blocking gradient flow. Today, Pre-LN is the default (GPT-2, GPT-3, LLaMA).
The diagram below shows the Pre-LN layout. Toggle to Post-LN to see how the order changes. Click any block for details. (The “Want to Go Deeper?” section at the bottom of this page has an animated gradient flow comparison.)
Click any block for details
Input / Output
Layer Norm
Transform (Attn / FFN)
Residual Add
Residual arc: carries the original signal around the transform
Pre-LN (GPT-2, LLaMA): Normalize before each transform. The residual path stays clean, making training stable without warmup.
What to look for: Data flows top to bottom through two sub-layers (Gather and Think). Each sub-layer has the same pattern: normalize, transform, add back. The dashed arcs on the right carry the original signal around each transformation.
Sub-layer 1 (Gather):
x′=x+MultiHeadAttn(LN(x))
Sub-layer 2 (Think):
output=x′+FFN(LN(x′))
Where:
x: the token’s vector entering this block (shape: dmodel, e.g. 512 dims)
LN(x): Layer Normalization, rescales x to mean ≈ 0 and std ≈ 1. Applied before each sub-layer in Pre-LN, so the residual path (x+…) stays clean.
MultiHeadAttn(…): the attention output, a small update based on context from other tokens
FFN(…): the feed-forward output, a small update from per-token processing
x+…: the residual connection. The original signal x always passes through. The sub-layer only needs to learn the change, not the full representation from scratch.
Reading the two equations together: take the input x, normalize it, gather context via attention, add the result back to x. Then normalize again, process through FFN, add back again. Same shape in (dmodel), same shape out (dmodel), but now enriched with context and processed features.
Worked example (4-dim vectors for simplicity):
Step
Values
Operation
x
[1.0, 2.0, 0.5, -0.3]
Token enters the block
LN(x)
[0.2, 1.4, -0.4, -1.3]
Normalized to mean≈0, std≈1
Attn(LN(x))
[0.1, -0.2, 0.3, 0.0]
Small nudge from attention
x′=x+Attn
[1.1, 1.8, 0.8, -0.3]
Original + nudge (mostly preserved)
LN(x′)
[0.3, 1.3, -0.1, -1.5]
Normalize again
FFN(LN(x′))
[-0.1, 0.2, 0.1, -0.1]
Small nudge from FFN
output=x′+FFN
[1.0, 2.0, 0.9, -0.4]
Final output, close to input but refined
The attention and FFN outputs are small adjustments, not rewrites. The residual connection ensures most of the original signal survives each block.
class TransformerBlock: def __init__(self, d_model, n_heads, d_ff): self.attn = MultiHeadAttention(d_model, n_heads) self.ffn = FeedForward(d_model, d_ff) self.ln1 = LayerNorm(d_model) self.ln2 = LayerNorm(d_model) def forward(self, x, mask=None): # Sub-layer 1: Attention x = x + self.attn(self.ln1(x), mask) # Sub-layer 2: FFN x = x + self.ffn(self.ln2(x)) return x
Four lines of code for the entire block.
Worked Example: One Token Through a Block
Trace the word “sat” (from “The cat sat”) through a single transformer block. Step through each operation to see how the vector transforms (4-dim vectors for simplicity):
Input vector for "sat"
x
0.5
-0.3
0.8
1.2
The token vector for "sat" entering the block. 4 dimensions shown (real transformers use 512+).
What to look for: The attention and FFN outputs are small nudges, not dramatic rewrites. The residual adds preserve most of the original signal. After both sub-layers, the output has the same shape as the input but carries richer information. This output feeds into the next block, which repeats the same gather-then-think pattern. A typical model stacks 12 to 96 blocks deep. (Why do we need residual connections at all? They keep gradients healthy in deep networks. Full explanation here.)
✍️Fill in the Blanks
Each transformer block has two sub-layers: first lets tokens communicate, then the lets each token process information independently. Both sub-layers are wrapped with connections so the original signal always passes through.
Fill in every blank, then check your answer.
A blank is still empty.
Fill in every blank before checking your answer.
Not quite.
Try another answer, or reveal the solution.
Correct.
One accepted answer is shown in each blank.
Answer revealed.
The blanks now show the answers.
The Three Transformer Variants
A single transformer block can process any sequence. But different tasks have different constraints. Translation needs to read a full sentence before writing the output. Text generation must work left-to-right, never peeking ahead. Sentence classification needs to see the whole input at once. One architecture can’t optimally serve all three. The choice comes down to a single constraint: which tokens can attend to which?
Attention Mask Comparison
Click a token to highlight its attention row
Bidirectional (Encoder / BERT)
Every token sees every other token
The
cat
sat
on
the
mat
The
cat
sat
on
the
mat
Causal (Decoder / GPT)
Each token sees only itself and earlier tokens
The
cat
sat
on
the
mat
The
×
×
×
×
×
cat
×
×
×
×
sat
×
×
×
on
×
×
the
×
mat
Rows = which token is asking (query). Columns = which tokens it can look at (keys). Darker = higher attention weight.
What to look for: Click “sat” in both matrices. In the bidirectional matrix (encoder), “sat” attends to all 6 tokens, including “on”, “the”, “mat” that come after it. In the causal matrix (decoder), “sat” can only see itself and the two tokens before it. The blocked cells (x) are set to negative infinity before softmax, giving them zero weight. This single constraint is what separates the three variants.
Encoder-Decoder (Original Transformer, T5, BART)
Transformer Architecture
Encoder
×N
Add & Norm
Feed Forward
Add & Norm
Multi-Head Self-Attention
+
Positional Encoding
Input Embedding
Inputs
encoder output
Decoder
Output Probabilities
Softmax
Linear
×N
Add & Norm
Feed Forward
Add & Norm
Multi-Head Cross-Attention
Add & Norm
Masked Multi-Head Self-Attention
+
Positional Encoding
Output Embedding
Outputs (shifted right)
Click any component to learn more about it
The original 2017 “Attention Is All You Need” architecture uses both columns: an encoder to read the input and a decoder to generate the output.
How it works: The encoder processes the full input with bidirectional self-attention: every word sees every other word. It produces a set of context-rich representations. The decoder generates output one token at a time using causal self-attention (can only see previous output tokens), plus cross-attention that reads from the encoder’s representations.
Cross-attention is the bridge: the decoder’s queries ask “what part of the input do I need right now?”, and the encoder’s keys and values provide the answer.
Cross-Attention in TranslationClick a French token to see its attention
"chat" attends 85% to "cat", 10% to "sat", 5% to "The". The model learns word alignment from data alone.
What to look for: Click each French token. “chat” attends 85% to “cat”, “assis” to “sat”, “Le” to “The”. The model learns this alignment from training data alone, without explicit word-pairing rules. (Forgot cross-attention? Review it here.)
Best for: Tasks where input and output are different sequences: translation, summarization, speech-to-text. T5 showed this architecture works for almost any NLP task by framing it as text-to-text.
🤔Quick Check
In an encoder-decoder transformer, where do the keys and values for cross-attention come from?
Your turn
Choose an answer to check your understanding.
Try another option
Cross-attention connects two sequences. Which part provides the information being read?
Correct!
In cross-attention, queries come from the decoder (what do I need?) and keys/values come from the encoder's output (what information is available from the input). This lets the decoder selectively read from the encoded input at each generation step.
Answer: B
In cross-attention, queries come from the decoder (what do I need?) and keys/values come from the encoder's output (what information is available from the input). This lets the decoder selectively read from the encoded input at each generation step.
Attempts: 0
Encoder-Only (BERT)
Transformer Architecture
Encoder
Contextualized Representations
[CLS] → ClassificationAll → Token tasks (NER)
×N
Add & Norm
Feed Forward
Add & Norm
Multi-Head Self-Attention
+
Positional Encoding
Input Embedding
Inputs
Click any component to learn more about it
What if you don’t need to generate text at all? Drop the decoder, keep only the encoder stack.
How it works: Every token sees every other token through bidirectional self-attention. There’s no causal mask, no generation. The model reads the entire input simultaneously and produces contextualized representations for each token.
This matters for understanding tasks. Consider the word “bank” in two sentences: “I sat by the river bank” vs “I went to the bank to deposit money.” A bidirectional model sees “river” to the right and resolves the ambiguity. A causal model processing left-to-right would have to guess without seeing what comes after.
The [CLS] trick: BERT prepends a special [CLS] token to every input. After passing through all layers, this token’s representation captures a summary of the entire sequence. For classification tasks (sentiment, spam detection), you just feed [CLS]’s final vector through a linear layer and softmax.
The [MASK] trick: During training, BERT randomly replaces ~15% of tokens with [MASK] and learns to predict the original. This “fill in the blank” objective (masked language modeling) forces the model to build deep bidirectional understanding. Deep dive into BERT.
Best for: Classification, named entity recognition, sentence similarity, question answering (extractive).
Limitation: Cannot generate text. There’s no autoregressive mechanism, no way to produce one token at a time.
🤔Quick Check
Why can BERT disambiguate the word 'bank' better than a left-to-right model?
Your turn
Choose an answer to check your understanding.
Try another option
Think about which words help you understand the meaning of 'bank' in 'the river bank'...
Correct!
Bidirectional attention lets each token see every other token, including words that come after it. When 'bank' can see 'river' to its right, it gets strong context for the 'riverbank' meaning. A causal (left-to-right) model would have to guess based only on the words before 'bank'.
Answer: B
Bidirectional attention lets each token see every other token, including words that come after it. When 'bank' can see 'river' to its right, it gets strong context for the 'riverbank' meaning. A causal (left-to-right) model would have to guess based only on the words before 'bank'.
Attempts: 0
Decoder-Only (GPT, LLaMA, Claude)
Transformer Architecture
Decoder (GPT-style)
Output Probabilities
Softmax
Linear
×N
Add & Norm
Feed Forward
Add & Norm
Masked Multi-Head Self-Attention
+
Positional Encoding
Output Embedding
Outputs (shifted right)
Click any component to learn more about it
The simplest design: just the decoder stack, no encoder, no cross-attention. One job: predict the next token.
Step through the animation below. At each position, the model can only see the tokens before it (causal attention), and it predicts what comes next:
Next-Token Prediction
Position 1: given "The", predict the next word. All 1 token are processed in parallel during training, but only the last position's prediction matters for generation.
What to look for: At position 1, “The” is all the model has, and it guesses “cat.” At position 2, it sees “The cat” and guesses “sat.” Each step adds one more token of context. The curved arrows show which tokens are visible to the current position: always a growing left-to-right window, never peeking ahead. During training, all four positions are computed in parallel (the causal mask blocks future tokens). During generation, they happen one at a time.
“Decoder-only”? But it clearly understands input. The name is confusing, and Karpathy has argued that “autoregressive transformer” would be more accurate. Step through the animation below to see where the name comes from:
Why "Decoder-Only"?
Original Transformer (2017)
The original paper has two columns: an encoder (bidirectional attention) and a decoder (causal attention + cross-attention that reads from the encoder).
The model absolutely builds rich representations of its input (it “encodes” in the everyday sense), but architecturally its building block descends from Vaswani’s decoder column, not the encoder. The name is about lineage, not capability.
Why it won: Three reasons:
Simplicity. No encoder-decoder boundary, no cross-attention. One uniform stack of blocks. Fewer design choices means fewer things to get wrong.
Scaling. Decoder-only models scale predictably: more parameters, more data, better performance. The scaling laws discovered by Kaplan et al. (2020) showed smooth, power-law improvements across many orders of magnitude.
Emergent abilities. Next-token prediction turns out to be a surprisingly general objective. To predict what comes next in text, the model must learn grammar, facts, reasoning, and even some degree of world knowledge. GPT-3 showed that a large enough decoder-only model can do translation, summarization, and question answering without being specifically trained for them: just provide a few examples in the prompt (few-shot learning).
ChatGPT, Claude, and LLaMA are all which type of transformer?
Your turn
Choose an answer to check your understanding.
Try another option
Which architecture can generate text one token at a time?
Correct!
Modern LLMs are decoder-only transformers. They generate text one token at a time using causal (masked) self-attention. This simpler architecture scales well and the autoregressive nature makes it great for generation tasks.
Answer: C
Modern LLMs are decoder-only transformers. They generate text one token at a time using causal (masked) self-attention. This simpler architecture scales well and the autoregressive nature makes it great for generation tasks.
Attempts: 0
✍️Fill in the Blanks
Encoder-only models use attention (every token sees all others), while decoder-only models use attention (each token sees only previous tokens). The encoder-decoder variant uses both, connected by -attention.
Fill in every blank, then check your answer.
A blank is still empty.
Fill in every blank before checking your answer.
Not quite.
Try another answer, or reveal the solution.
Correct.
One accepted answer is shown in each blank.
Answer revealed.
The blanks now show the answers.
Computation Cost
Every token must attend to every other token. That means the attention matrix has n2 entries, and the cost grows quadratically with sequence length. Click through the sequence lengths below to feel the blowup:
Attention Cost: n² Growth
What to look for: Start at 512 tokens (our baseline), then click through to 128,000. At true scale, the first two bars are invisible compared to the last one. Toggle log scale to see all four, then switch back to true scale to feel the real gap. Going from 512 to 128,000 tokens means 62,500x more computation in the attention layer alone.
This quadratic cost is why long-context models are expensive, and why researchers developed efficient attention variants: Flash Attention (exact attention with better memory access patterns), sliding window attention (Mistral, attend to a local window only), and linear attention approximations.
The FFN is cheaper per token (O(n⋅d⋅dff), linear in sequence length) but uses more parameters. Embedding lookup is trivially cheap (O(n)).
🤔Quick Check
If a model handles 1,024 tokens and you double the sequence length to 2,048, how does the attention computation change?
Your turn
Choose an answer to check your understanding.
Try another option
The cost grows with the square of the sequence length...
Correct!
Attention cost is O(n²). Doubling n means (2n)² = 4n², so the cost quadruples. This is why going from 1K to 128K tokens is so expensive: the attention cost increases by 128² = 16,384x.
Answer: B
Attention cost is O(n²). Doubling n means (2n)² = 4n², so the cost quadruples. This is why going from 1K to 128K tokens is so expensive: the attention cost increases by 128² = 16,384x.
Attempts: 0
Quick Summary
Concept
What Happens
Intuition
Feed-Forward Network
Two linear layers with ReLU: expand to 4x, then contract back
Attention gathers; FFN thinks about what was gathered
Transformer Block
LN -> Attention -> Add -> LN -> FFN -> Add
A repeatable “gather then think” unit, stacked N times
Encoder-Decoder
Encoder reads full input; decoder generates output token by token
Translation: different input and output sequences
Encoder-Only (BERT)
Bidirectional attention, no generation
Understanding tasks: classification, similarity
Decoder-Only (GPT)
Causal attention, autoregressive generation
”Predict next token” is surprisingly general
O(n2) Attention
Attention matrix grows quadratically with sequence length
Doubling length = 4x the cost
Why Pre-LN Won Over Post-LN
Pre-LN vs Post-LN
Same three operations, different order. The only difference: where LayerNorm sits relative to the residual add.
Same three operations, different order. Click “Show Gradient Flow” to see why this matters: in Post-LN, gradients must pass through LayerNorm on the residual path, which scales the gradient by ∂LN/∂z at every layer. After 96 layers, this repeated scaling can cause vanishing gradients. In Pre-LN, the residual path is a clean identity (gradient factor = 1), so gradients flow freely no matter how deep the network.
Post-LN (original 2017):
output=LN(x+sublayer(x))
Gradient via residual: ∂x∂output=∂z∂LN⋅(1+∂x∂sublayer) — everything multiplied by ∂z∂LN.
Pre-LN (GPT-2+):
output=x+sublayer(LN(x))
Gradient via residual: ∂x∂output=1+∂x∂sublayer⋅∂x∂LN — the “1” term is a clean gradient highway.
The trade-off: Post-LN can sometimes achieve slightly better final performance, which is why some models like PaLM use a hybrid approach.
Where the Parameters Live
In a standard 12-layer GPT-2 (117M parameters):
Embedding layers: ~38M (33% of total)
Attention (all 12 layers): ~28M (24%)
FFN (all 12 layers): ~57M (49%)
Other (LN, output head): ~4M (3%)
The FFN dominates. This is why Mixture of Experts (MoE) targets the FFN specifically: replacing each FFN with 8 expert FFNs and routing each token to the top 2 gives 4x the parameters with only ~1.25x the computation.
The Evolution of Transformers
Year
Model
Architecture
Key Innovation
2017
Original Transformer
Encoder-Decoder
Self-attention replaces recurrence
2018
BERT
Encoder-only
Bidirectional pre-training (MLM)
2018
GPT-1
Decoder-only
Autoregressive pre-training
2020
GPT-3
Decoder-only
175B params, in-context learning
2023
LLaMA
Decoder-only
RoPE, RMSNorm, SwiGLU
2024+
GPT-4, Claude, Gemini
Decoder-only
RLHF, MoE, multimodal
The trend is clear: decoder-only architectures won.
Modern Architectural Innovations
RMSNorm (replaces LayerNorm): Simpler normalization that skips mean subtraction. Used by LLaMA, Gemma. ~10% faster.
Grouped Query Attention (GQA): Multiple query heads share K, V projections. Saves memory during inference with minimal quality loss.
Sliding Window Attention: Attend only to a local window (e.g., 4096 tokens). Information propagates globally across layers.
Mixture of Experts (MoE): Replace the single FFN with multiple “expert” FFNs. A router picks which 2 experts handle each token. Scales parameters without proportionally scaling computation.
Key References
The transformer. Vaswani et al., “Attention Is All You Need” (2017) introduced the encoder-decoder transformer with multi-head self-attention, positional encoding, and the two-sub-layer block structure described on this page.
Pre-LN stability. Xiong et al., “On Layer Normalization in the Transformer Architecture” (2020) showed that moving LayerNorm before each sub-layer (Pre-LN) stabilizes training and removes the need for careful learning rate warmup.
SwiGLU and gated FFNs. Shazeer, “GLU Variants Improve Transformer” (2020) compared gated linear unit variants for the FFN and found SwiGLU consistently outperforms ReLU. Now the default in LLaMA, Gemma, and most modern LLMs.
Scaling laws. Kaplan et al., “Scaling Laws for Neural Language Models” (2020) discovered that decoder-only transformer performance follows smooth power laws in parameters, data, and compute, providing the empirical foundation for the “scale up decoder-only” strategy.
Learning Checklist
I can explain the FFN’s role: attention gathers, FFN thinks, and why the expand-then-contract architecture matters
I can describe the two sub-layers in a transformer block and how residual connections and layer normalization wrap each one
I know the difference between encoder-only, decoder-only, and encoder-decoder architectures and when each is used
I understand why decoder-only architectures dominate modern LLMs
I can explain why attention’s O(n2) cost matters and name at least one technique that addresses it
I can trace the high-level data flow: embeddings + position -> N transformer blocks -> output
Next: Training
You understand the architecture: what each component does and how they fit together. But a freshly initialized transformer produces random noise. How does it learn? Training →