MAI study materials
MAI study resources

MAI: Generative AI and Large Language Models

MAI · Work through your exam, one topic at a time.

All guide sections

Generative AI and Large Language Models

What this domain tests

How transformers produce text, how pretraining differs from fine-tuning and retrieval, and how to control cost, latency, and hallucination in a deployed LLM application.

Core rules

  • Self-attention computes weighted sums of value vectors, with weights from scaled dot products of queries and keys (divided by the square root of the key dimension). Multi-head attention runs several of these in parallel; causal masking prevents attending to future tokens.
  • Training stages: pretraining on next-token prediction, supervised fine-tuning on demonstrations, then preference alignment such as RLHF or DPO.
  • Prompting levers: instructions, few-shot examples, chain-of-thought, and schema-constrained structured output.
  • RAG chunks documents, embeds them into a vector index, retrieves top-k passages, optionally reranks, and injects them into context. It grounds answers, supports citations, and keeps knowledge current without retraining.
  • Fine-tuning shapes behaviour, style, format, and tool use. It is unreliable for injecting facts that change often.
  • Sampling controls: temperature, top-p, max tokens. Use temperature 0 for extraction and classification tasks.

Worked example

A support assistant must answer from a 50,000-document policy corpus that changes weekly and must cite sources. Reasoning: fine-tuning would need weekly retraining and still could not cite reliably, so choose RAG. Embed and index the corpus, retrieve top-k per question, rerank, and require the answer to quote retrieved passages or decline when similarity is below a threshold.

Traps that cost marks

Fine-tuning to add fresh facts. Assuming a big context window removes the need for retrieval. Shipping without a labelled evaluation set. Ignoring prompt injection arriving through retrieved documents. Estimating cost by word count when billing is per token.