The MLP Mixes Features at Each Position
The Transformer MLP expands and contracts each token record with shared weights but no cross-position communication. Trace two records, derive projection shapes, test independence, and count parameters.
After attention exchanges information across positions, the block applies the same multilayer perceptron to every token record independently. A basic two-projection MLP is
For model width and hidden width ,
The MLP expands the feature axis and contracts it again. It does not change sequence length.
Trace Two Positions Independently
Let , , use ReLU, omit biases, and choose
For , the expanded values are . ReLU gives , so the output is .
For , the expanded values are . ReLU gives , so the output is .
The weights are shared, but each position follows its own calculation.
Position-Wise Does Not Mean Feature-Wise
Changing one token record must not alter another token's MLP output. Within one record, however, each hidden unit can combine every input feature, and each output coordinate can combine every hidden unit. The MLP is independent across positions but dense across features.
This gives a useful implementation test: copy an input sequence, alter one position, run only the MLP, and confirm that all other output positions remain unchanged.
Count the Learned Entries
With two biases, the parameter count is
For and , this is . A count that omits biases must say so.
Q1. Count a two-projection MLP
How many learned entries does a biased MLP have when and ?
Compute it first, then check your number.