4.1.8 · D1Transformer Architecture

Foundations — Feed-forward network sublayers

1,911 words9 min readBack to topic

Before you can read the parent note, you must be fluent in a small pile of symbols. This page defines each one from absolute zero: plain words → the picture → why the topic needs it. Read top to bottom; every item leans on the one above it.


1. A number line and a vector

Picture a scalar as one dot on a ruler. A vector is several rulers side by side, each holding its own dot. The whole collection of dots is the vector.

Figure — Feed-forward network sublayers

Why the topic needs it: a Transformer never processes "a word." It processes the word's vector — its list of numbers. In the parent note, is exactly such a list.


2. Dimension and the symbol

Read aloud as "the space of all lists of length ." The is a fancy letter for "real numbers" (any number on the ruler, including decimals and negatives). The little superscript is just the length.

Why the topic needs it: the FFN's entire job is described by how the dimension changes — . You cannot follow "expand then contract" without knowing what a dimension is.


3. Multiplying a vector by a matrix ()

The single most important operation in the whole topic is — feeding a vector into a matrix to get a new vector of possibly different length.

Figure — Feed-forward network sublayers

Why the topic needs it: (expansion) and (projection) are both this operation. The number of columns of decides the output length — that is literally how the FFN changes dimension. If has columns, the output has slots.


4. The bias and the affine step

Picture as choosing a direction and steepness; the bias slides the whole result along so the detector can fire at the right threshold. Without a bias, every detector would be forced to pass through zero.

Why the topic needs it: both FFN layers are . The bias is what lets a neuron say "fire only when the pattern is strongly present," not merely "present at all."


5. Non-linearity, and why a curve is mandatory

Here is the pivotal question the whole topic answers: why bother with two layers and a curve — why not one big matrix?

Figure — Feed-forward network sublayers

To make the network able to draw bent decision boundaries, we must insert something that is not a straight line between the two matrices. That "something" is an activation function.

Why this tool and not another: a matrix answers "which linear combination?"; only a curve can answer "should this feature turn on or stay off?" — a decision matrices structurally cannot make. See Activation Functions and Universal Approximation Theorem for why any smooth curve, given enough width, unlocks any continuous function.


6. Reading the activation symbols: , , , ,

The parent throws several curve-symbols at you. Here they are, each with its picture.

Figure — Feed-forward network sublayers
Recall Which curve is the hard hinge?

Which of the four has a sharp corner and a totally flat left side? ::: ReLU — ; the others are smooth everywhere.

Why the topic needs all four: the parent traces the evolution ReLU → GELU → SiLU. GELU is built from (or its stand-in); SiLU is built from . You cannot read that story without knowing each symbol's shape.


7. Subscripts, sequences, and "position-wise"

Picture a sentence as a row of boxes, one box per word, each box holding that word's vector.

Why the topic needs it: this single idea separates the FFN from an ordinary neural net. The mixing between boxes was already done earlier by attention; the FFN deliberately works one box at a time. This is also why it links to Residual Connections and Layer Normalization, which wrap the FFN box-by-box.


8. The residual wrapper: and LayerNorm

Why the topic needs them: the parent's final formula is . Both pieces are context you must already own; contrast with Batch Normalization vs Layer Normalization for why it normalizes per-vector, not per-batch.


Prerequisite map

scalar and vector

dimension d and R space

matrix multiply xW

bias add xW plus b

non-linearity is mandatory

activation curves ReLU GELU SiLU

sequence index and position-wise

residual plus LayerNorm wrapper

Feed-forward Network Sublayer


Equipment checklist

Self-test: cover the right side and answer each.

I can say in words what means
A list of 768 real numbers — one token's feature vector.
I know what decides the output length of
The number of columns of .
I can state why needs
Rows of must match the input length; columns set the new length.
I can explain what the bias does
Shifts every output by a fixed amount, letting a neuron pick its firing threshold.
I know why we cannot skip the activation curve
Two matrices with no curve collapse into one matrix — no non-linearity, no bent boundaries.
I can name the shape of ReLU vs
ReLU = flat then ramp (a hinge); = smooth S from 0 to 1.
I can read
Probability a standard bell-curve value is ; the area under the left of the bell.
I can define "position-wise"
Same network applied to each token separately, no cross-token mixing.
I know what is called and why
A residual connection — the block learns only the change, easing training.