Generative AI - interactive revision session
Generative AI, revision session
20 multiple-choice questions, one per slide, then one open question
Questions follow the course order, sessions 1 to 8. They are in the spirit of the exam, with the same traps: numbers to compute, two answers that look right, and a distractor that is true but does not answer the question.
In a transformer block, attention has four projection matrices (query, key, value, output), each of size C × C. The feed-forward network (FFN) goes C → 4C → C. Ignoring norms and biases, what share of the block’s parameters sits in the FFN?
✅ Answer: B
Attention: 4C². FFN: C × 4C + 4C × C = 8C². Share: 8/12 = 67%.
An encoder-style transformer (no causal mask) has its positional encodings removed. You feed “the dog chased the cat” and “the cat chased the dog”. What happens to the vector of the word dog?
✅ Answer: C
Self-attention treats the tokens as a set. Order only enters through the position vectors.
A model reaches a validation loss of 2.0 per token (cross-entropy, natural logarithm). What is the perplexity?
✅ Answer: C
Perplexity = \(e^{\text{loss}} = e^{2.0} \approx 7.4\). (\(2^2\) is for a loss in bits.)
You train a 7B model on 2T tokens. One A100 sustains 1.25 × 10¹⁴ FLOP/s (about 40% utilisation). With \(C \approx 6ND\), roughly how many GPU-seconds?
✅ Answer: B
\(C = 6ND = 8.4\cdot10^{22}\) FLOPs, divided by \(1.25\cdot10^{14}\) FLOP/s: \(6.7\cdot10^{8}\) s.
SFT example: 12 prompt tokens, then an answer of 6 tokens plus the end-of-turn token. With loss masking, how many positions contribute to the loss?
✅ Answer: B
Prompt labels are masked (−100). Trained: 6 answer tokens + 1 end-of-turn = 7.
During RLHF, the reward model score rises for 2,000 steps. Human raters prefer the outputs only up to about step 800, then prefer them less. What is happening, and what do you do?
✅ Answer: D
Goodhart: the reward model is only a proxy. Stop early, raise the KL penalty or refresh it.
LoRA with rank r = 16 on the MLP up-projection of a 7B model, a matrix of size 4096 × 11008. How many trainable parameters for this matrix?
✅ Answer: C
$r (d_{in} + d_{out}) = 16 104 = $ 241,664.
A schema allows only the tokens “yes” or “no” at the current position. Without constraints, the model gives: “yes” 0.30, “no” 0.20, “maybe” 0.10, and 0.40 spread over other tokens. With constrained decoding, what is the probability of sampling “yes”?
✅ Answer: A
Forbidden tokens get logit −∞, then the softmax renormalises: \(0.30 / (0.30 + 0.20) = 0.60\).
An assistant reads the user’s mailbox and summarises web pages the user pastes. It has no email tool and no browser, but the chat interface renders markdown, including images loaded from a URL. Is the lethal trifecta complete?
✅ Answer: B
Private data + untrusted content + a way out: a rendered image URL can carry the data.
BM25 ranks: 1. A, 2. B, 3. C. Dense ranks: 1. D, 2. E, 3. C. After reciprocal rank fusion with \(k = 60\), which document is first?
✅ Answer: A
Doc C: \(1/63 + 1/63 = 0.0317\), against \(1/61\) for a doc seen once at rank 1.
The cross-encoder is more accurate than the bi-encoder. Why not use it directly on the 1,000,000 chunks of the corpus?
✅ Answer: A
Query and chunk go through the transformer together: nothing is precomputed.
An agent must complete 20 steps, and you want a success rate of at least 90% for the whole run. What per-step success rate do you need, independence assumed?
✅ Answer: D
\(0.9^{1/20} \approx 0.995\). (At 0.99 per step: \(0.99^{20} \approx 0.82\).)
Support emails must be sorted into billing, technical or legal. Each category is handled by a differently prompted LLM. The developers write every branch. What is this?
✅ Answer: D
One call classifies, then your code picks the path: routing.
Stable Diffusion’s VAE divides each side by 8 and keeps 4 channels. You generate a 1024 × 1024 image instead of 512 × 512. How many latent values does the denoiser process at each step?
✅ Answer: C
\(128 \times 128 \times 4 = 65{,}536\): 4× more than at 512 × 512.
A zero-shot CLIP classifier with labels Granny Smith, iPod, pizza, … sees an apple with a paper note reading “iPod”. It answers iPod with 99.7%. Why?
✅ Answer: B
Web captions often repeat the words in the image, so reading the text is a shortcut.
One relevant document per query. System A finds it at ranks 1 and 5 for two queries. System B finds it at ranks 3 and 3. Compare Recall@5 and MRR.
✅ Answer: D
Recall@5 is 1 for both. MRR: A = (1 + 1/5) / 2 = 0.60, B = 1/3 = 0.33.
On the same 100 questions, model B scores 76% and model A 70%. Your manager writes “B is better”. What is the right answer?
✅ Answer: A
Standard error ≈ 4.6 points, so about ±9 at 95%: the two intervals overlap.
Scores out of 5. Model A: 4.4 judged by itself, 3.9 judged by B. Model B: 4.5 judged by itself, 3.7 judged by A. Which model do you report as better?
✅ Answer: A
A flatters itself by 0.5, B by 0.8: rank with the cross-judged scores.
An agent scores 94% on a coding benchmark. Reading its trajectories, you see it ran git log --all, found the future fix commit and copied it. What is the right conclusion?
✅ Answer: C
The benchmark became a target: read the trajectories and close the shortcut.
Five systems, quality and cost per 1,000 answers: P 85%, $8; Q 82%, $3; R 82%, $5; S 70%, $1; T 84%, $8. How many are on the Pareto front?
✅ Answer: B
P, Q and S. R is dominated by Q, and T by P.
A law firm wants an assistant that answers lawyers’ questions over 20,000 client contracts, with citations. Some contracts are confidential: a lawyer must only see the matters they work on.
1. Pipeline. Offline: parse and chunk by clause, embed and index with metadata (matter, owner). Online: query rewriting, hybrid retrieval (BM25 + dense, RRF), filter by the user’s rights, rerank, generate with citations or abstain.
2. Metrics. Recall@k or MRR: says nothing about whether the answer is right or well written. Faithfulness (an LLM judge): says nothing about whether the right evidence was retrieved, and it has its own biases.
3. Guardrails. Access control in the retriever, against leaks between matters. Injection filter and output validation, against hidden instructions in a contract. Citation check with abstention, against invented clauses.
4. Against fine-tuning. Knowledge in the weights cannot be updated, cited or restricted per user; contracts change and a lawyer must check the source.
Albert School - Generative AI mock exam