Exercises

Practice ID validation, lookup, positions, block parameters, shapes, tied logits, shared identity, cross-entropy, masked means, causal interventions, and end-to-end failure diagnosis.

Use the frozen vocabulary, dimensions, position table, and parameter conventions. Show intermediate values for numerical answers.

Q1. Validate an ID window

Is input [0,2,7,8] valid for the frozen model? If not, identify the first invalid value.

Answer it first, then check.

Hint
Compare each ID with V=8V=8.
Solution
No. ID 8 is outside [0,8)[0,8).
Not attempted
Review

Not marked done.

Q2. Calculate position-aware lookup

Token B has row [0,0,1,0][0,0,1,0]. What record represents it at position 2?

Compute it first, then check your number.

Hint
Use the third row of the frozen position table.
Solution
[0,0,1,0]+[0,0,0.1,0]=[0,0,1.1,0][0,0,1,0]+[0,0,0.1,0]=[0,0,1.1,0].
Not attempted
Review

Not marked done.

Q3. Count one decoder block

Under the frozen conventions, count attention matrices, biased MLP, and two LayerNorms for one block.

Compute it first, then check your number.

Hint
Do not add attention biases; do include MLP biases.
Solution
4(4×4)+(4×8+8+8×4+4)+2(8)=1564(4\times4)+(4\times8+8+8\times4+4)+2(8)=156.
Not attempted
Review

Not marked done.

Q4. Track every major shape

For B=2,T=3B=2,T=3, give the ID, residual-stream, final-record, and logits shapes.

Answer it first, then check.

Hint
Use ID rank 2, model width 4, and vocabulary width 8.
Solution
(2,3)(2,3), (2,3,4)(2,3,4), (2,3,4)(2,3,4), and (2,3,8)(2,3,8).
Not attempted
Review

Not marked done.

Q5. Calculate two tied logits

For h=[1,2,3,0.5]h=[1,-2,3,0.5], calculate tied logits for D with embedding [1,1,0,0][1,1,0,0] and Y with embedding [0,0,1,1][0,0,1,1].

Answer it first, then check.

Hint
Add coordinates selected by the 1s in each embedding.
Solution
zD=12=1z_D=1-2=-1 and zY=3+0.5=3.5z_Y=3+0.5=3.5.
Not attempted
Review

Not marked done.

Q6. Distinguish sharing from copying

Two matrices begin numerically equal, but changing an embedding entry leaves the output matrix unchanged. Are the weights tied?

Answer it first, then check.

Hint
Ask whether one update affects both operations.
Solution
No. The implementation copied values into independent parameters.
Not attempted
Review

Not marked done.

Q7. Calculate one cross-entropy

For logits [0,0][0,0] and target index 1, calculate natural-log cross-entropy.

Compute it first, then check your number.

Hint
Use log(1/2)-\log(1/2).
Solution
log(0.5)=log20.693147-\log(0.5)=\log2\approx0.693147.
Not attempted
Review

Not marked done.

Q8. Calculate a masked mean loss

Per-position losses are [1,2,9,9][1,2,9,9] and valid-target mask is [1,1,0,0][1,1,0,0]. What mean loss should be reported?

Compute it first, then check your number.

Hint
Do not divide by all four positions.
Solution
(1+2)/(1+1)=1.5(1+2)/(1+1)=1.5.
Not attempted
Review

Not marked done.

Q9. Design a causal intervention

Using zero-based indices, to test whether logits row 1 reads future position 3, what should you change and what should remain invariant?

Choose the intervention and invariant

Select one choice, then check.

Hint
Alter only information the query is forbidden to read.
Solution
Change only the token at position 3. With fixed parameters and earlier inputs, logits row 1 must remain unchanged.
Not attempted
Review

Not marked done.

Q10. Audit a misleading successful run

A model returns shape (2,4,8)(2,4,8) and finite loss, but reports 400 parameters while configured as tied. Changing the token at the fourth input position (index 3) also changes logits row 1. Identify both independent failures.

Choose both failures

Select one choice, then check.

Hint
Compare parameter count with 368 and test forbidden dependence.
Solution
The model likely stores an independent unembedding matrix, adding 32 entries, and its causal mask or preprocessing permits future leakage.
Not attempted
Review

Not marked done.

Pause and reflect

Which exercises were difficult, what mistake pattern did you notice, and what should you practice again? The note stays with this exercise set.

0 of 10 exercises marked done

Review

Not marked done.