Mock exam

Generative AI - interactive revision session

Lambert Fatoux

Mock exam

Generative AI, revision session

20 multiple-choice questions, one per slide, then one open question

How it works

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.

Session 1: Transformer

Q1. The share of the FFN

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?

  • A. About 50%
  • B. About 67%
  • C. About 33%
  • D. About 75%

✅ Answer: B

Attention: 4C². FFN: C × 4C + 4C × C = 8C². Share: 8/12 = 67%.

Q2. No positional encoding

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?

  • A. It differs between the two sentences, since attention depends on word order
  • B. The model cannot run, because the softmax needs position indices to work
  • C. It is identical in both: without positions, the model sees a bag of words
  • D. It is identical only in the sentence where “dog” appears first in the text

✅ Answer: C

Self-attention treats the tokens as a set. Order only enters through the position vectors.

Session 2: Pretraining and scaling laws

Q3. From loss to perplexity

A model reaches a validation loss of 2.0 per token (cross-entropy, natural logarithm). What is the perplexity?

  • A. 2.0
  • B. 4.0
  • C. 7.4
  • D. 100

✅ Answer: C

Perplexity = \(e^{\text{loss}} = e^{2.0} \approx 7.4\). (\(2^2\) is for a loss in bits.)

Q4. How long does it take?

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?

  • A. About 6.7 × 10⁷
  • B. About 6.7 × 10⁸
  • C. About 6.7 × 10⁹
  • D. About 6.7 × 10¹⁰

✅ Answer: B

\(C = 6ND = 8.4\cdot10^{22}\) FLOPs, divided by \(1.25\cdot10^{14}\) FLOP/s: \(6.7\cdot10^{8}\) s.

Session 3: Post-training

Q5. Which tokens learn?

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?

  • A. 19
  • B. 7
  • C. 6
  • D. 12

✅ Answer: B

Prompt labels are masked (−100). Trained: 6 answer tokens + 1 end-of-turn = 7.

Q6. The reward keeps climbing

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?

  • A. Underfitting: train for longer, and the humans will end up agreeing
  • B. Catastrophic forgetting: lower the learning rate and restart training
  • C. The reward model is too small to judge: nothing can be done about it
  • D. Reward hacking: stop early, raise the KL penalty, retrain the reward model

✅ Answer: D

Goodhart: the reward model is only a proxy. Stop early, raise the KL penalty or refresh it.

Q7. LoRA on a wider matrix

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?

  • A. 65,536
  • B. 176,128
  • C. 241,664
  • D. 721,420,288

✅ Answer: C

$r (d_{in} + d_{out}) = 16 104 = $ 241,664.

Session 4: Advanced prompting

Q8. Constrained decoding

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”?

  • A. 0.60
  • B. 0.30
  • C. 0.50
  • D. 1.00

✅ Answer: A

Forbidden tokens get logit −∞, then the softmax renormalises: \(0.30 / (0.30 + 0.20) = 0.60\).

Q9. The trifecta, without any tool

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?

  • A. No: nothing can send data out, the model only writes text
  • B. Yes: a rendered image URL is a way out that can carry data
  • C. No: summarising is a read-only operation, so nothing leaks
  • D. Yes, but only if the model is small and easy to fool

✅ Answer: B

Private data + untrusted content + a way out: a rendered image URL can carry the data.

Session 5: Production-grade RAG

Q10. Who wins after fusion?

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?

  • A. Doc C, found by both retrievers
  • B. Doc A, the best BM25 result
  • C. Doc D, the best dense result
  • D. Doc B, which has the best average rank

✅ Answer: A

Doc C: \(1/63 + 1/63 = 0.0317\), against \(1/61\) for a doc seen once at rank 1.

Q11. Why not rerank everything?

The cross-encoder is more accurate than the bi-encoder. Why not use it directly on the 1,000,000 chunks of the corpus?

  • A. It needs one forward pass per (query, chunk) pair, with no precomputing
  • B. It cannot read passages longer than the query, so it truncates them
  • C. It produces a score, not a vector, so it understands less meaning
  • D. It only works for languages other than English, so it is not usable here

✅ Answer: A

Query and chunk go through the transformer together: nothing is precomputed.

Session 6: Agents and tools

Q12. The reliability budget

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?

  • A. 90%
  • B. 95%
  • C. 99%
  • D. 99.5%

✅ Answer: D

\(0.9^{1/20} \approx 0.995\). (At 0.99 per step: \(0.99^{20} \approx 0.82\).)

Q13. Which pattern?

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?

  • A. An autonomous agent
  • B. Orchestrator-workers
  • C. Prompt chaining
  • D. A routing workflow

✅ Answer: D

One call classifies, then your code picks the path: routing.

Session 7: Diffusion and multimodal

Q14. A bigger image

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?

  • A. 16,384
  • B. 32,768
  • C. 65,536
  • D. 262,144

✅ Answer: C

\(128 \times 128 \times 4 = 65{,}536\): 4× more than at 512 × 512.

Q15. The apple that became an iPod

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?

  • A. The image encoder has a bug that appears with handwritten text on objects
  • B. Captions on the web repeat the words in the image: reading text is a shortcut
  • C. The contrastive loss cannot see text inside an image, so the note is noise
  • D. The classifier was fine-tuned on electronic products, biasing it to “iPod”

✅ Answer: B

Web captions often repeat the words in the image, so reading the text is a shortcut.

Session 8: Evaluation

Q16. Same recall, different quality

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.

  • A. B has the higher Recall@5, because its ranks are more regular
  • B. B has the higher MRR, because its two ranks are identical
  • C. The two systems have the same MRR, since both find the document
  • D. Same Recall@5 (1.0); A has the higher MRR (0.60 against 0.33)

✅ Answer: D

Recall@5 is 1 for both. MRR: A = (1 + 1/5) / 2 = 0.60, B = 1/3 = 0.33.

Q17. Is 76% better than 70%?

On the same 100 questions, model B scores 76% and model A 70%. Your manager writes “B is better”. What is the right answer?

  • A. Not established: each score carries about ±9 points of noise
  • B. Yes: 6 points is a large gap, so B is the better model
  • C. Yes, provided both models were run at temperature 0
  • D. No: B is worse, since a high score on few questions is suspect

✅ Answer: A

Standard error ≈ 4.6 points, so about ±9 at 95%: the two intervals overlap.

Q18. The flattering judge

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?

  • A. A: cross-judged 3.9 beats 3.7, and self-scores are inflated
  • B. B: 4.5 beats 4.4, so B wins with the higher overall score
  • C. A tie: the gaps are under half a point, so they are equal
  • D. Neither: an LLM judge cannot be used to compare models

✅ Answer: A

A flatters itself by 0.5, B by 0.8: rank with the cross-judged scores.

Q19. 94% on the benchmark

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?

  • A. The score is valid: the agent only used tools it was given
  • B. Add more tasks of the same kind, to average the shortcut out
  • C. It measures lookup, not skill: close the leak, add private tasks
  • D. Use a stronger LLM judge to grade the final patches again

✅ Answer: C

The benchmark became a target: read the trajectories and close the shortcut.

Q20. The Pareto front

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?

  • A. 2
  • B. 3
  • C. 4
  • D. 5

✅ Answer: B

P, Q and S. R is dominated by Q, and T by P.

Open question

Mock open question: a law-firm assistant

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. Give the main stages of the pipeline, from contracts to cited answer
  2. Give two metrics (one for retrieval, one for the answer) and what each cannot tell you
  3. Name two guardrails and the risk each one covers
  4. A colleague proposes fine-tuning the model on the 20,000 contracts instead. Give two arguments against

Mock open question: model answer

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.