Architectures

Convolutions for spatial structure, recurrent models for sequences, and transformers: tokens, embeddings, self-attention, positional information.

CNN Concepts

A convolution slides one small set of weights over the whole input. That weight sharing is a belief about the data — the same pattern matters wherever it appears — and it is the reason a CNN needs far fewer examples than a fully-connected net on pixels.

Q · A fully-connected network on raw pixels memorises the training images and fails on new ones. What does a convolution change, and what does it assume about the data?
Sequence Models

A recurrent network carries a hidden state step by step through a sequence; that is elegant and it is why long dependencies were hard. Transformers replaced the recurrence with attention so every position can be computed in parallel — and simpler models still win many forecasting problems.

Q · Recurrent networks read a sequence one step at a time. Why did that make long-range dependencies hard to learn, and what did transformers change about the computation?
Transformer Fundamentals
▶ lab

Tokens become embeddings, attention mixes information across positions, a feed-forward layer transforms each position on its own, and residual connections plus normalisation let dozens of those blocks stack. Knowing where the parameters and FLOPs live is what turns "use a transformer" into a cost you can budget.

Q · What does a transformer block actually compute, where do its parameters and FLOPs live, and why does the context length set the serving cost?
Self-Attention
▶ lab

Every token asks a question (query), every token advertises what it holds (key), and each token's new representation is a softmax-weighted mix of what the relevant tokens carry (value). The formula fits on one line; the weights it produces are a computation, not an explanation.

Q · How does a token decide which other tokens matter, what is the formula, and what can and cannot be read off the attention weights?
Positional Information

Attention is a weighted sum over a set: shuffle the tokens and it computes the same thing. Order has to be injected explicitly — learned, sinusoidal, relative or rotary — and the scheme you pick decides whether the model can say anything sensible past the lengths it was trained on.

Q · Attention treats its input as a set. How does a transformer know which token came first, and why does a model degrade on inputs longer than it was trained on?