This page assumes nothing. Before you can read the parent note, you need to be fluent in a handful of symbols and pictures. We build each one from scratch, in an order where every item leans on the one before it.
Before any math, look at what we are even feeding the machine.
Figure 1 — Two rows of boxes. The cyan row (top) is the input sequence "I love AI", labelled x1,x2,x3. The amber row (bottom) is the output "J'aime l'IA", labelled y1,y2. What to observe: three boxes go in, two come out — the white arrow and caption "3 in → 2 out" show that the two rows have different lengths. That mismatch is the whole reason this architecture exists.
A sequence is just an ordered list of things. "I love AI" is a sequence of three words. Order matters: "AI love I" is a different sequence even though it uses the same words.
WHY the topic needs this: the whole reason encoder-decoders exist is that the input list and the output list can have different lengths (Tx=Ty). Translation turns a 3-word English sequence into a 2-word French one. No fixed-size machine could do that directly — hence two machines.
A neural network cannot add up the letters "l-o-v-e." It only does arithmetic on numbers. So each token must first become a list of numbers, called a vector.
Figure 2 — Word to number-column. On the left, the cyan word "love"; the amber arrow labelled emb( ) feeds it into the white column of four numbers on the right. What to observe: the word does not stay a word — it becomes a fixed list of numbers (here R4; in real code R512). This is the only form the network's arithmetic can touch, which is why every token must pass through this arrow first.
WHY the topic needs this: when the parent writes "c∈R512", the bold letter and the R512 are saying "c is a vector of 512 real numbers." You need the vector idea to even read that line.
This is the heart of the encoder. The parent writes:
htenc=fenc(xt,ht−1enc)
Read it as a sentence: "the new memory (ht) is made by a function f that looks at the current token (xt) and the old memory (ht−1)."
h = hidden state = the machine's running memory / notepad.
ht−1 = the memory one step ago (subtract 1 from the seat number → the previous seat).
f = the fixed rule that mixes "what I just read" with "what I remembered." The samef is reused at every step (that is what "recurrent" means — the loop reuses one rule).
Figure 3 — The recurrence unrolled. Read it left to right. The amber boxes at the bottom are the tokens "I", "love", "AI"; each feeds upward (white arrow) into a cyan memory circle h1,h2,h3. The horizontal white arrows carry the old memory forward into the next circle — that is the "same rule f reused each step" (noted top-left). What to observe: the last circle h3 is pulled out (amber arrow) and renamed c, the context pill. Nothing new is invented for c; it is literally the final memory.
WHY the topic needs this: the context vectorc is nothing but this final snowball, c=hTxenc. The whole "squeeze the sentence into one pill" idea is this recursion run to the end.
The actual f can be a plain RNN cell, an LSTM, or a GRU — the parent note lets you swap in any of these. They differ only in how carefully they decide what to keep and what to forget.
W and b — a weight matrixW multiplies a vector to reshape/rescale it; a biasb is a vector added on. Together Wv+b is the network's adjustable "knobs" (the parameters it learns). Different subscripts (Wh, Why, Wo) are just different knob-sets for different jobs.
tanh — the hyperbolic tangent. It is a function that takes any number and gently squashes it into the range (−1,1).
Figure 4 — The tanh curve. The horizontal axis is the raw input z (any number); the vertical axis is the output. What to observe: the cyan S-curve is nearly a straight line through the origin (small signals pass through almost unchanged) but flattens toward the two amber dashed lines at +1 and −1 (huge signals get clamped). No input, however large, escapes the band (−1,1) — that is exactly why the memory cannot blow up.
z = logits = raw, unbounded scores the network outputs, one per possible word in the vocabularyV (the full list of words the model knows). zv is the score for word v.
exp(z) means ez, the exponential. Why exponentiate? Because exp turns any number (even negative) into a positive one, and it stretches gaps: a slightly higher score becomes a much higher weight. This lets the model express confident preferences.
∑u∈V = "add up over every word u in the vocabulary." The big Σ is just a compact "add all of these."
Dividing each exp(zv) by that total sum forces all the values to add up to exactly 1.
P(yt∣y<t,x) in words: "the probability of the next output token yt, given (∣) all the tokens generated before it (y<t, meaning y1,…,yt−1) and the input x."
The training objective chains all those per-step probabilities together.
The product ∏: the expression ∏t=1TyP(yt∗∣y<t∗,x) means "multiply these probabilities for every step t from 1 to Ty." The star superscriptyt∗ marks the ground-truth correct token — the answer key we are trying to match (it is not an exponent). We multiply because the probability of the whole correct sentence is the chance of getting step 1 right and step 2 right and so on.
Why the log? Multiplying many numbers each less than 1 gives a tiny number the computer can't store safely (underflow). The logarithmlog turns a product into a sum:
log(∏tPt)=∑tlogPt
Sums are stable and easy to differentiate. That single identity is why the parent's loss suddenly switches from ∏ to ∑.
The minus sign and N1: training minimizes a cost, but we want to maximize likelihood — so we flip the sign (maximize L = minimize −L) and divide by the number of examples N to get an average.
Here θ (theta) is the bundle of all the W's and b's — every knob in both networks. Training = nudging θ to make this number small. The nudging itself is done by backpropagation through time.
The decoder feeds its own last output back in as the next input — this is autoregressive ("self" + "regress on past outputs"). At each step it faces a choice of which word to emit. Two strategies appear in the parent:
Greedy: always take the single highest-probability word. Fast, but can paint itself into a corner.
Beam search: keep the best few partial sentences alive at once. See beam search for the full mechanism.