Module 2 · Inside the block

The feed-forward half, where most of the model is

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 6 of 10 in this chapter

This chapter’s goalImplement single-head attention from scratch in NumPy, explain which half of a block holds most of the parameters and which half moves information between positions, and predict how grouped-query attention, key-value caching and a mixture-of-experts design each change memory and speed.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

The bigger half, and the less discussed one

Attention gets the attention. But in the model you counted in module one, attention was 42 million parameters per layer and the feed-forward network was 176 million. Roughly two-thirds of a transformer is this second half, and it operates on each position entirely on its own, with no knowledge of its neighbours.

Its structure is simple:

Python
def mlp(x):                        # x is one position's vector, width 4096
    a = gelu(x @ W_up)             # project up to 14336
    return a @ W_down              # project back down to 4096

Up, nonlinearity, down. Modern models use a gated variant, SwiGLU, which computes two up-projections and multiplies them element-wise before the down-projection: three matrices instead of two, and a consistent small quality gain that nobody has a fully satisfying theory for.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘The feed-forward half, where most of the model is’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/the-feed-forward-half (Accessed: 29 November 2026).