S1439 of 55
0 XP
  1. Hook
  2. Problems

S14 · Problem set 7

Problem set 7: recurrent and gated cells, gradients through time, transformers' parameters, arithmetic and caches, attention weights, Bayesian networks and explaining away, messages on chains, Laplace and variational approximations, and an EM step

These problems cover lessons 24 to 37, with the weight on sequences, attention, graphical models and approximate inference: sizing recurrent and transformer models and what they cost to train and serve, following gradients and attention weights through them, reasoning with Bayesian networks, and approximating posteriors that have no closed form.

Check

An LSTM layer with 128 hidden units reads 40-dimensional inputs, over sequences 1000 steps long.

(a)

How many parameters does it have?

(b)

About how many million multiply-adds does one sequence's forward pass take?

Check

Backward signals through a recurrent network change by about a factor of 0.95 per step. Separately, a gradient of norm 500 is clipped to 5.

(a)

By what factor does a signal change over 20 steps?

(b)

By what factor does clipping scale the gradient?

Check

An LSTM cell should start training with a memory time constant of 50 steps.

(a)

What forget-gate value gives that?

(b)

What forget-gate bias produces it?

Check

A transformer has width 2048, 24 layers and a 128000-token vocabulary, and trains on 2 trillion tokens on hardware sustaining 0.4 of a 1000 TFLOP/s peak.

(a)

How many billion parameters does it have?

(b)

How many days does training take?

Check

A model with 32 layers of width 4096 serves 32768-token contexts with a 16-bit key–value cache, on a device with 192 GB of memory, 14 GB of which hold the weights.

(a)

How much cache does one sequence need?

(b)

How many sequences fit at once?

Check

A query's raw dot products with two keys are 24 and 16, in 64 dimensions.

(a)

What attention weight does the first key get?

Check

A transformer layer of width 768 attends over 1024 positions.

(a)

What fraction of the layer's per-token arithmetic is attention itself?

Check

In a Bayesian network, a node with 3 states has two parents with 2 and 4 states.

(a)

How many free parameters does its conditional table need?

(b)

How many would a full joint table over the three variables need?

Check

Two independent faults (priors 0.02 and 0.05) trip an alarm with probabilities 0.99 and 0.95 (noisy-OR), which also trips on its own with probability 0.001.

(a)

What is the first fault's probability given the alarm?

(b)

And given the alarm and the second fault?

Check

A two-state chain stays in state 1 with probability 0.8 and moves from state 2 to 1 with probability 0.1. It's observed in state 1 at time 1.

(a)

What is the probability it's in state 1 at time 3?

Check

Counts are Poisson with rate λ; λ has a gamma(1, 10) prior, and 15 events occur in time 500.

(a)

Where is the Laplace approximation centered?

(b)

What standard deviation does it give?

Check

A Gaussian posterior has standard deviations 1 and 0.5 and correlation 0.9; a mean-field approximation minimizes KL(q‖p).

(a)

What standard deviation does the first factor get?

(b)

And the second?

(c)

What is KL(q‖p)?

Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.

Practice

Keep practicing

15 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.