In words
What it is, why it matters, and what it is like.
Why am I learning this?
Understanding the feed-forward block completes your picture of a transformer layer. It is the part that holds most of the model's parameters and where a lot of the model's factual knowledge is stored. You will need it to comprehend how GPT models generate text, why scaling up models works, and how techniques like retrieval-augmented generation hook into the model. Without this, you have only half of the transformer story.
The idea, in plain terms
Imagine a transformer layer as a factory assembly line. Self-attention is the section where workers share information with each other—each worker looks at what everyone else is doing and adjusts their part accordingly. After that, each worker takes their updated part and runs it through a private 'processing room'—a little machine that transforms it in a specific way. This processing room is the feed-forward block. It does not communicate with the other workers; it works on its own piece, applying a learned transformation. The transformation usually expands the piece into a larger intermediate form and then contracts it back, allowing the model to consider more complex features before the next attention round.
An analogy
Think of a chef preparing a multi-step dish. The 'attention' step is like tasting all the ingredients together to decide how they might combine. The 'feed-forward' step is like marinating each ingredient separately in a secret spice mix—each one goes through its own transformation without looking at the others. The spice mix has a lot of ingredients (the expanded dimension), and the final marinade is a reduced, concentrated version (the contracted dimension). This analogy works well because it shows that attention mixes information across positions, while feed-forward processes each position independently and identically—you use the same spice mix on every ingredient. Where it breaks down: in a real transformer, the feed-forward block is not a 'secret' spice mix; it is a learned function that is applied to every position equally, and it is not pre-defined—it is adjusted during training to help the model make better predictions.
Definition
A feed-forward block is a small neural network applied independently to each position in a sequence, consisting of two linear transformations with a nonlinear activation in between, typically expanding the dimension and then contracting it back, which allows the model to learn complex features at each position.
Where this sits
This concept builds directly on the transformer architecture. After self-attention, each position passes through a feed-forward block. You have notes on Multi-Head Attention, Causal Attention Masking, and Positional Encoding—these are the other components of a transformer layer. Together, they form the repeating block that is stacked to build models like GPT. This block is also crucial for the GPT Architecture that you have notes on, as the decoder blocks are exactly composed of masked self-attention and feed-forward layers.