Highlights

Contents

Part II
02

Turning a hidden vector into predictions

The final representation must become a prediction. Normalization controls its scale before vocabulary scoring. Weight tying shares a tensor across input and output, so training must combine both gradient routes.

THE TRAINING CHAPTER: TEN PARTS, ONE COMPLETE MODEL1. features2. output3. examples + loss4. optimizer5. precision6. resume + loop7. evaluation8. experiments9. decoding10. whole pipelineforward computation → learn parameters → measure results → generate

#Section 3Final normalization

Imagine two final token vectors pointing in the same direction, one with larger magnitude. A linear head can turn that scale difference into a much sharper distribution even if the relative preferences are unchanged. The last residual addition also bypasses the normalization at the start of its sublayer. A pre-norm stack therefore usually has one more normalization after the final block.

Final normalization is the normalization applied to the last residual-stream tensor before the vocabulary projection. It acts on each token’s feature dimension, preserving B × T × d. It is separate from the two norms inside each Finch-24 block. “Every block has a norm” does not establish that the tensor leaving the last residual addition is normalized.

Final normalization controls the stream entering the vocabulary head. It acts over each token’s features, not across the batch. See normalization conventions.

THE FINAL RESIDUAL ADDITION BYPASSES THE BRANCH NORMresidual xbranch normbranch update+final RMSNorm → LM head[3,4] / 3.535534[0.848528, 1.131371]normalize the stream that actually reaches the head
Figure 3.5A pre-norm block normalizes its branch input, then adds to the residual stream. The final RMSNorm acts after the last addition, immediately before the vocabulary head.
RMS NORMALIZATION CHANGES RADIUS BEFORE THE LEARNED GAINfeature 1feature 2[3, 4]same directionsmaller radius[0.848528, 1.131371]unit gain; epsilon omitted for this calculation
Figure 3.6The illustrative vector [3, 4] keeps its direction under unit-gain RMS normalization when epsilon is omitted. Orange shows the calculated normalized radius; learned unequal gains can also change direction.

What the final hidden representation means

A hidden representation is an internal numeric description learned for the prediction task. Here it has combined the current input token with all permitted earlier positions through the block stack. Coordinate meanings need not be individually named or stable across retraining. The head reads the whole vector to assign vocabulary scores.

Normalization controls a scale presented to the head and helps the chosen architecture train. It does not make logits probabilities, ensure calibrated predictions, or stop the learned head weights from growing. Learned gains may also change the normalized scale. RMSNorm’s scale invariance is approximate in the presence of epsilon and assumes positive input rescaling. It is not invariance to adding a constant, which LayerNorm has before its learned affine transformation.

Sensitive squared-value reductions can use higher precision than surrounding matrix multiplications. This protects normalization without changing its feature-wise role.

Ba, Kiros and Hinton introduced LayerNorm in 2016; Zhang and Sennrich introduced RMSNorm in 2019. Llama 3’s reference forward pass applies its final RMSNorm before its output projection. Norm placement belongs to the trained architecture: moving or deleting it in a checkpoint changes the function. LayerNorm, RMSNorm, Llama 3 implementation.

#Section 4LM head

The final vector has 512 coordinates, but Finch-24 has 32,000 possible next tokens. We need one score for every candidate, not a rule saying “coordinate seven is the word cat.” A vocabulary projection supplies that learned interpretation.

The language-model head, or LM head, is the projection from the final hidden width to vocabulary scores. The earlier LM head defines logits and stable softmax explains the score-to-probability conversion. A logit is an unnormalized score; a probability is a nonnegative share of a distribution that sums to one. Logits can be negative, larger than one, or shifted by the same constant without changing their softmax probabilities.

Z=X^Wout,pb,t,v=exp⁡(Zb,t,v)∑u=1Vexp⁡(Zb,t,u).Z=\widehat{X}W_{\text{out}},\qquad p_{b,t,v}=\frac{\exp(Z_{b,t,v})}{\sum_{u=1}^{V}\exp(Z_{b,t,u})}.

Read this as: multiply the normalized hidden tensor X^\widehat{X} by the output matrix WoutW_{\text{out}} to obtain logits ZZ; at batch index bb and position tt, exponentiate candidate vv's logit and divide by the sum of exponentials over all vocabulary candidates uu. WoutW_{\text{out}} has shape (d,V)(d,V) in the row-vector convention. There is no output bias in Finch-24.

The output shape is B × T × V, so our example is (2, 8, 32000). Every sequence position gets its own next-token distribution. The logits at position tt predict the token after that input position, using the causal prefix through tt. During generation, only the last position's logits normally choose the next token; that does not mean training should discard the others.

EVERY POSITION OWNS A VOCABULARY-SIZED SCORE ROWB = 2T = 8one targetV = 32,000 scores per rowdrawn columns are symbolic; actual output shape is (2, 8, 32000)
Figure 3.7The Finch-24 output has two sequences, eight positions per sequence, and 32,000 vocabulary scores per position. Drawn columns are symbolic; one row supplies one supervised target prediction.

A miniature vocabulary

The head compares the final representation with each candidate's learned vector. Stable softmax subtracts the largest score before exponentiating and normalizing, as illustrated below.

EACH VOCABULARY ROW SCORES THE SAME HIDDEN VECTORh = [1,2]A: [2,0]20.665241B: [1,0]10.244728C: [0,0]00.090031vocabulary rowslogitssoftmaxscores first; a distribution after normalization
Figure 3.8An illustrative three-token head turns a two-feature vector into logits. The vocabulary rows define three dot products; softmax then converts scores into a distribution.

A stable softmax subtracts the maximum logit before exponentiation. This leaves the distribution unchanged because the common exponential factor cancels, but avoids overflow from large positive scores. If a row has no finite allowed candidate, softmax cannot create a valid distribution; check the mask and filtering policy before sampling.

The cost is visible at small scale

A large vocabulary makes the logits tensor substantial. Tying weights saves a parameter matrix, not the output activations.

Fused or chunked loss implementations can avoid retaining every logit during training. At generation prefill, projecting only the last position avoids scores that will not be used.

#Section 5Weight tying

Input lookup and output scoring both connect vocabulary items with features. One learned table can perform both jobs, avoiding a second independent matrix.

The embedding lookup and weight-tying mechanism are already established. Keep their convention: input rows come from EE of shape (V,d)(V,d), and a tied output uses E⊤E^\top. The new concern here is how that shared parameter receives gradients and optimizer state.

zv=h⋅Ev,∇EL=∇ELinput path+∇ELoutput path.z_v=h\cdot E_v,\qquad \nabla_E\mathcal{L}=\nabla_E\mathcal{L}_{\text{input path}}+\nabla_E\mathcal{L}_{\text{output path}}.

Read the first expression as: candidate vv's score zvz_v is the dot product of the normalized hidden vector hh and embedding row EvE_v. Read the second as: because both uses refer to the same parameter EE, the loss gradient on that parameter adds the contributions through input lookup and output scoring. The path subscripts label contributions to the same loss, not separate objectives.

The input lookup sends gradients only to rows that appeared as input, apart from any other regularization. The full-softmax output path generally sends gradients to every vocabulary row. A rare token can therefore receive output-side updates even if it did not occur in this particular input batch. Sharing does not force the token's final contextual vector to equal its input embedding.

TWO USES, ONE PARAMETER OBJECTE: (32000, 512)16,384,000 parametersinput lookup E[ids]output scores h Eᵀbackward adds both paths to E.grad
Figure 3.9One stored (32000, 512) parameter supplies both input rows and output dot products. The backward pass adds both paths' contributions to the same gradient tensor.

Tied and untied are architectural choices

Property Tied head Untied head
Unique vocabulary matrices One Two
Input/output geometry Shared Independently learned
Finch-24 unique parameters 40,509,952 56,893,952
Gradient routes to embedding Lookup and head Lookup only
Head arithmetic Dense projection Dense projection
Checkpoint requirement Restore aliasing Restore separate weights

Weight tying can reduce storage and influence generalization, but it constrains the model's input and output representation spaces. It is not universally better. Press and Wolf's work on output embeddings helped establish it for language models. The original Llama 3 8B has separate token embeddings and output weights, so its parameter count includes both vocabulary matrices. Weight tying, Llama 3's two parameter objects.

python
embedding = torch.nn.Embedding(V, d)
head = torch.nn.Linear(d, V, bias=False)
head.weight = embedding.weight   # same Parameter, not a copied value

The assignment must happen before constructing the optimizer, and the optimizer must not receive duplicate references to the same parameter. Loading equal numeric matrices is insufficient if they become independent parameters afterward. A useful identity check is head.weight is embedding.weight.

#Section 6The complete decoder forward pass

Put our eight input IDs on a whiteboard. We can now follow their tensors without any missing "and then the model predicts" step. Use the classic complete decoder and the finished modern block for the architectural derivation. Here we retain the training shape trace and parameter references, rather than repeat the attention or SwiGLU explanation.

A forward pass is one evaluation of the model's operations with fixed current parameters. Token IDs select rows from the embedding. Each block applies RMSNorm, causal grouped-query attention with RoPE, and a residual addition; then RMSNorm, SwiGLU, and another residual addition. The final RMSNorm prepares the residual stream for the tied vocabulary projection.

X(0)=E[ids],U(ℓ)=X(ℓ)+Attn⁡ℓ(Norm⁡a,ℓ(X(ℓ))),X(ℓ+1)=U(ℓ)+FFN⁡ℓ(Norm⁡f,ℓ(U(ℓ))).X^{(0)}=E[\mathrm{ids}],\quad U^{(\ell)}=X^{(\ell)}+\operatorname{Attn}_{\ell}(\operatorname{Norm}_{a,\ell}(X^{(\ell)})),\quad X^{(\ell+1)}=U^{(\ell)}+\operatorname{FFN}_{\ell}(\operatorname{Norm}_{f,\ell}(U^{(\ell)})).

Read this as: the initial hidden tensor X(0)X^{(0)} is the embedding lookup for the input IDs; block ℓ\ell adds its attention update to make U(ℓ)U^{(\ell)}, then adds its feed-forward update to make the next residual tensor X(ℓ+1)X^{(\ell+1)}. The norms labeled aa and ff belong to the attention and FFN branches. Blocks have independent weights; sharing across positions does not mean sharing across depth.

Attention uses a head-first layout before returning to the residual stream. RoPE rotates queries and keys; ordinary training evaluates full causal sequences without a persistent generation cache.

THE VOCABULARY AXIS APPEARS ONLY AT THE HEADtoken IDs(2, 8)embedding rows(2, 8, 512)8 decoder blocks(2, 8, 512)final RMSNorm(2, 8, 512)tied vocabulary head(2, 8, 32000)token positions stay; the last dimension changes
Figure 3.10Finch-24’s complete forward pass preserves the token grid through the block stack, then changes the feature axis from 512 to the 32,000-token vocabulary.

Parameter flow is not parameter movement

Each operation reads the parameter tensors that belong to it. The embedding and head read the same stored object, and each block reads its own projection and gain tensors. Activations flow between operations; weights do not get passed down the sequence as if they were tokens. No optimizer updates happen inside this forward pass. The graph records the dependencies needed to differentiate the eventual loss in Section 10.

Evaluation mode and disabled gradient recording are separate controls. The first changes training-only behavior; the second prevents a derivative graph.