Fundamentals of Generative AI
What makes generative AI different
Traditional ML predicts a label or a number. Generative AI produces new content such as text, images, audio, and code. Foundation models are very large models pretrained on broad data that can then be adapted to many downstream tasks instead of being built task by task.
Transformers, tokens, and embeddings
Large language models are transformer-based. Text is split into tokens, and each token maps to a numeric embedding vector. Self-attention lets the model weigh relationships among all tokens inside the context window. The training objective is next-token prediction, which explains both fluency and hallucination: the model optimizes plausible continuations, not verified truth.
The model lifecycle
- Pretraining: self-supervised learning over huge unlabeled corpora; extremely expensive; produces a base model.
- Adaptation: instruction tuning, fine-tuning, and reinforcement learning from human feedback shape behaviour using labelled or preference data.
- Inference-time techniques: prompt engineering and retrieval-augmented generation steer behaviour without changing weights.
Decoding controls
Temperature and top-p control randomness. Low temperature gives deterministic, repeatable, factual output; high temperature gives varied, creative output. A max-token setting bounds output length, and the context window bounds how much input plus output the model can consider at once.
Traps candidates miss
- RAG versus fine-tuning: RAG injects fresh or private knowledge at query time; fine-tuning changes style, format, and task behaviour and is an unreliable knowledge store.
- Hallucination is not solved by a larger model alone; grounding with retrieved sources and guardrails mitigates it.
- Diffusion models for images and GANs with a generator and discriminator are not autoregressive text LLMs.
Worked example
An internal policy chatbot invents citations. Adding retrieval over the policy documents, plus a prompt that requires citing retrieved passages, treats the root cause (missing grounding) faster and more cheaply than fine-tuning.