前馈网络 · 每个 token 各自加工Feed-Forward Network · Each Token Gets Its Own Pass
token position → expand → activate → contract
前馈网络(Feed-Forward Network,FFN)是对每个位置独立应用的多层非线性变换。Transformer 不只有注意力:注意力先汇总信息,FFN 再逐位置加工。A Feed-Forward Network (FFN) applies the same multilayer nonlinear transform to each position independently. A Transformer is more than attention: attention gathers information, then the FFN processes each position.
01 · 像四张照片各自过同一个滤镜01 · Like four photos through the same filter
信息已经送到每个 token 手里后,谁负责让它各自“消化”一遍?Once information reaches each token, what lets every position process it on its own?
▣▣
02固定注意力结果,只调 FFNHold Attention Fixed, Adjust the FFN
逐位置加工型Position-wise transform
位置数Positions
4
各自处理processed separately
位置间连线Cross-position links
0
正常为零zero by design
输出形状Output shape
4 × 2
逐位置返回one per position
注意力输出保持固定;此页只改变 FFN 的两组教学权重。Attention output stays fixed. Only the two teaching FFN weights change here.
03FFN 的 4 个零件Four Parts of an FFN
同规则,不串线Shared, not mixed
PART 01
每个位置输入Position input
每张 token 卡拿到注意力已经汇总好的表示。Each token card receives a representation already gathered by attention.
PART 02
升维扩张Expand
第一层把表示展开到更宽的中间空间。The first layer opens the representation into a wider hidden space.
PART 03
非线性激活Nonlinearity
负值被压低,强响应得以保留并组合。Negative values are suppressed while strong responses can combine.
PART 04
降回原宽度Contract
第二层把加工结果送回该 token 的输出位。The second layer returns the processed result to that token's output slot.
04最小机制:同一个 FFN 分别作用于每个位置Minimal Mechanism: The Same FFN Acts on Each Position
FFN(xi) = W2σ(W1xi + b1) + b2
xi → W1 → σ → W2 → yi
下标 i 从头到尾不变:这一页里没有 xj 进入 yi。Index i stays unchanged end to end: no xj enters yi on this page.
调 W1Adjust W1中间条形扩张Hidden bars expand
经过 σPass through σ负响应被截断Negative response clips
调 W2Adjust W2该卡输出收缩That card contracts
05边界实验:强行让 token 互相串线Boundary Test: Force Tokens to Cross-Link
让第 1 张卡的输入流进第 4 张卡输出。这会制造位置间混合,与本页定义冲突。Route card 1 input into card 4 output. That creates cross-position mixing, contradicting this page's definition.
尚未执行。正常 FFN 的位置间连线为 0。Not run yet. A normal position-wise FFN has zero cross-position links.
✗ FFN 负责 token 彼此查看。The FFN makes tokens inspect one another. → ✓ 注意力负责汇总,FFN 负责逐位置加工。Attention gathers; the FFN processes each position.
✗ 每个 token 都有完全不同的 FFN。Each token gets a different FFN. → ✓ 同一组参数应用到所有位置。The same parameters apply at every position.
✗ 线越多,FFN 越强。More links make a stronger FFN. → ✓ 位置间连线会改变机制类别。Cross-position links change the mechanism.
06 · 一句话带走06 · One line to keep
FFN 用同一组多层非线性规则分别加工每个 token;拖两组权重时,每张卡都会变,但位置之间始终不串线。An FFN uses the same multilayer nonlinear rule on every token independently. Adjust either weight and every card changes without cross-position links.