TensoriumInterview preparation
← Home

Core concepts · 62 topics

A guided path through the ideas behind modern LLMs.

Read the stages in order: how text becomes a prediction, what happens inside the Transformer block, how a model learns, then serving, scale, and post-training. Every topic names what to know first, then gives the intuition, the math with concrete numbers, the common misconception, and a self-check. Already comfortable with the basics? Switch to By area and jump straight to a topic.

New to machine learning? Start here instead.

These topics work best as a refresher; they assume ideas like probability and loss. Begin with three short beginner lessons (tokens, embeddings, next-token prediction), then the visual walkthrough for attention and the Transformer.

Finish line: You can explain how text becomes a prediction and what training does to improve that prediction.

Topic 09 of 62 · Inside the Transformer block

FFNs and residual connections

Easy

Why does a Transformer need feed-forward layers and residual connections in addition to attention?

Why this mattersThe feed-forward network holds roughly two-thirds of a dense Transformer’s parameters and is the layer that sparse Mixture-of-Experts replaces.

1 · Start with the intuition

Attention and the feed-forward network (FFN) divide the work of a Transformer block along two orthogonal axes: attention moves information across token positions, while the FFN applies a nonlinear feature transformation within each token position independently. Residual connections wrap both sublayers (y = x + F(x)) so gradients have a direct identity highway back to early layers and each sublayer only needs to learn a refinement Δx to the running representation.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Mix across tokens (Attention)

Each token gathers context from eligible earlier tokens via attention and adds the result to the residual stream.

Next, we will look at: Transform within each token (FFN). Move on when this operation makes sense.

Visualizing the behavior

Pre-norm Transformer block: two residual corrections

identityidentityxNormAttentionmixes tokens+NormFFNper token+
Attention moves information between positions; the FFN transforms each position on its own. The dashed identity paths carry x forward unchanged, so each sublayer adds a correction and gradients have a direct route back.

Where block parameters live (d = 4096, full MHA, no biases)

Derived
Classic FFN: 2 matrices, hidden 4d201.3 M
67.1
134.2
SwiGLU FFN: 3 matrices, hidden 8d/3201.3 M
67.1
134.2
  • Attention projections (4d²)
  • FFN (8d²)
The FFN holds about two-thirds of each block’s parameters. SwiGLU uses three matrices, so its hidden width is cut to about 8d/3 to keep the same 8d² (implementations round it, e.g. 11,008 for d = 4096). GQA would shrink the attention share further.