ERA V5session 01
From neural networks to the transformer.
01Neural network
Learns to find patterns. It predicts, compares the prediction with the actual answer, and adjusts its state. Repeat n times until it reaches the goal state.
This figure needs JavaScript.
02Biological neurons
- Decides how much to pass on. Incoming signals add up in the cell body; it fires only when the total crosses a threshold.
- Talks to many others. Each neuron connects to thousands of others (not to every other one).
- Spiking. Neurons fire in spikes and can stay silent, a bit like sleeping. Spiking neural networks borrow this.
This figure needs JavaScript.
03Neuron
Multiply, add, squish. A weighted sum of the inputs, plus a bias, passed through an activation function.
z = x₁·w₁ + x₂·w₂ + x₃·w₃ + b a = f(z)
This figure needs JavaScript.
Bias lost importance. With y = mx + b it matters. But today x spans x₁ … xbillion, so the chance of every input being zero is tiny, and normalisation layers re-centre values anyway. LLaMA and PaLM drop biases from their linear layers.
04Activation functions
- ReLU: negative → 0, else x; max(0, x). Dying ReLU: if a neuron gets stuck in the negative zone, its output and its slope are both 0, so it sleeps forever.
- Sigmoid: squishes x between 0 and 1.
- Step: below zero → 0, above zero → 1. Its slope is 0 everywhere, so there's nothing to learn from.
- GELU: a smooth ReLU that lets small negatives through.
- Swish: x · sigmoid(x), also smooth and slightly negative near 0.
Without them, stacked layers collapse into a single linear map (S1-2 proves it).
This figure needs JavaScript.
05Feed-forward network
Neurons in layers; each layer's output is the next layer's input, flowing one way from input to output.
We can have a different number of neurons in each layer, but we prefer the same number for computation reasons: GPUs run big, regular matrix multiplies fastest.
This figure needs JavaScript.
06Loss and gradient descent
Loss: how wrong the network's answer is. Gradient descent: change the weights in the direction that reduces the loss, w ← w − η · ∂L/∂w. The learning rate η sets the step size.
This figure needs JavaScript.
07Language
Two challenges: positional information (order changes meaning) and contextual awareness (a word's meaning depends on its neighbours).
This figure needs JavaScript.
08Embeddings
Each token becomes a vector: a row of a learned table. Tokens used in similar ways end up close together. S1-3 shows this emerge from next-token training alone.
This figure needs JavaScript.
09RNN
Reads a sentence one word at a time and carries a running summary of what it has read so far: the hidden state.
hₜ = tanh(W_h · hₜ₋₁ + W_x · xₜ + b)
Because it's sequential, it can't be parallelised, and the running summary tends to forget the past when the context is long.
This figure needs JavaScript.
10Attention
Achieved through Query, Key and Value.
- Query: the information the word is looking for.
- Key: the information the word can offer to other words.
- Q·K: the strength of that connection (scaled by √dk, then softmaxed into weights).
- Value: what actually gets passed along, weighted by that strength.
This figure needs JavaScript.
11Residual connections and normalisation layers
- Residual connection: add a layer's input to its output, x + f(x). The layer only learns a change, and gradients get a shortcut through deep stacks.
- Normalisation layer: rescale each vector to mean 0, spread 1, so values don't blow up or fade out layer after layer.
This figure needs JavaScript.