6.5.1 · D3Research Frontiers & Practice

Worked examples — Reading and reproducing ML papers

3,511 words16 min readBack to topic

Before any symbol appears, a promise: every quantity that shows up in a formula here will first be named in plain words. If you see , you will already know it means "how many numbers are in one query vector". Nothing is assumed.


The scenario matrix

When you reproduce a paper, the difficulties fall into a handful of repeating cell classes. Think of this table as a checklist of "have I met this monster before?"

Cell Class of situation What makes it tricky Example that covers it
A Normal happy path Everything stated, you just rebuild it Ex 1
B Missing detail (paper omits init / LR) You must infer an unstated choice Ex 2
C Degenerate input — zero / empty / length-1 Formula must not divide by zero or crash Ex 3
D Sign / direction case — gradient can grow OR vanish Same formula, opposite behaviour Ex 4
E Limiting behaviour — a quantity → 0 or → ∞ What happens at the extreme Ex 5
F Numbers don't match — you're off from the paper Is it a bug or noise? Ex 6
G Real-world word problem — "should I even reproduce?" Cost/benefit decision, not maths Ex 7
H Exam-style twist — a subtle trap in the formula The "gotcha" they test you on Ex 8

Each example below is tagged with its cell. Together they touch every row.

Recall Which cell is the scariest and why?

Cell F (numbers don't match) ::: because you cannot tell from the number alone whether it is a real bug or ordinary random variation — you need a statistical answer, not a guess.


Cell A — The happy path

Look at the figure below: it traces the shapes through the pipeline like water through pipes. Even without seeing the image, here is what it shows in words — a box of shape flows right into a box of shape (pair scores), then into a scale-and-softmax box still (row weights), then into a final box that returns to — the same shape it started with.

Figure — Reading and reproducing ML papers

Cell B — The missing detail


Cell C — Degenerate input


Cell D — The sign / direction case

Look at the figure below: two "gradient highways", one with a weak on-ramp, one with a subtractive ramp. In words, it shows the learned path ( or ) running alongside the identity path (), and the two adding to give and respectively — both non-zero.

Figure — Reading and reproducing ML papers

Cell E — Limiting behaviour

Look at the figure below: it plots two curves against . In words — the unscaled spread climbs steeply ( at up past at ), while the scaled spread sits flat on the line for every .

Figure — Reading and reproducing ML papers

Cell F — Numbers don't match


Cell G — The real-world word problem


Cell H — The exam-style twist


Recall Rapid-fire scenario recall

Attention output shape given input ? ::: — attention rewrites tokens, keeps count and width. Softmax of a single-element row equals? ::: exactly , for any value. Which degenerate sequence actually crashes attention? ::: the empty (zero-length) one — its softmax is a ; length-1 is safe. The in the residual gradient fails to protect the gradient only when? ::: the learned part's gradient equals exactly , which cancels the identity. Divisor that pins attention-score spread to 1 for all ? ::: . A 1.74-sigma gap from the paper means? ::: within normal seed noise — not a bug. Softmax over which axis in attention? ::: the key axis (last dim), so each query's row sums to 1.