dffd_{\text{ff}}

d_ff — the feed-forward width

Read "d f f". It is the width of the hidden layer inside the feed-forward block: traditionally 4 × d_model, and about 8/3 × d_model in gated versions like SwiGLU.

The feed-forward block widens each token's vector to dffd_{\text{ff}} numbers, applies a nonlinearity, and narrows it back to dmodeld_{\text{model}}. These two large matrices hold most of a transformer's parameters.

SwiGLU uses three matrices instead of two. To keep the parameter count the same, dffd_{\text{ff}} is cut to about 83dmodel\frac{8}{3}d_{\text{model}}: three matrices of width 83d\frac{8}{3}d hold as many numbers as two of width 4d4d. This keeps comparisons between the two designs fair.

Example

dmodel=768  ⟹  dff=4×768=3072d_{\text{model}} = 768 \;\Longrightarrow\; d_{\text{ff}} = 4 \times 768 = 3072

GPT-2 small.

Where the course uses it

Related terms