Generative Models Overview
From memorizing data to sampling from it
Generative models learn to produce new examples that resemble the training distribution — text, images, audio. At the core are density learners (LLMs by next-token, diffusion by denoising) that turn a corpus into a sampling engine.
What you will learn
- Distinguish discriminative vs generative modeling
- Describe what likelihood-based training does
- Compare LLMs, diffusion and autoregressive music/audio generators
What is this?
A generative model learns the probability distribution of the training data well enough to draw NEW samples from it. Discriminative models answer 'which class does x belong to'; generative models answer 'what does a plausible x look like'. Text: next-token (LLM). Images/speech: diffusion or GAN-style denoising. All share the same trick — train on a giant corpus, then sample the learned distribution at inference.
Why do you need it?
- One pretrained generative model performs many tasks because tasks are just conditioned sampling.
- Generating is different from classifying: it needs a full density/sampling machinery, not a decision boundary.
- Scale and compute turned fitted distributions into the most capable general systems in ML.
- Product value: anything you can sample, you can automate — drafts, art, voice, code, summaries.
Mental model
A forger studying thousands of master paintings
A generative model on its training distribution
The forger never copies a canvas wholesale; they absorb the palette, brushwork, composition — the 'distribution' — and then paint new canvases that could plausibly hang in the same museum. As long as the style pays, the forger succeeds.
How it works
- Choose a model family whose outputs are samples: text (token sequence), image (pixels), audio (frames).
- Train to maximize data likelihood: LLM maximizes P(next token | prefix); diffusion maximizes the denoising score.
- Neural nets act as samplers with different mechanics — autoregression, denoising, score flow.
- Conditioning narrows the sampling: prompt, class label, or image mask direct the distribution.
- Inference draws one sample per call; randomness gives variation, seeds make it reproducible.
Training fits a distribution; inference samples from it.
In production
- Text: assistants, code completion, summarization, translation (LLM + sampling).
- Image/speech: diffusion for art, avatars and voice synthesis.
- Enterprise: sales drafting, RAG answers, synthetic data for testing classifiers.
Best practices
- Treat the model as a sampler: control temperature/top-p, never as a deterministic database.
- Cache and template prompts for cost and latency first; model choice second.
- Define an evaluation — groundedness, factuality — before roll-out, not after.
- Pin the model version and seed for reproducibility in tests.
Common mistakes
- Querying an LLM for facts with zero grounding (no RAG) and treating output as truth.
- Measuring success by sample flavor instead of task metrics.
- Over-fitting to one sampling parameter combo instead of evaluating across them.
- Assuming bigger always equals faster/better answers — latency and cost scale too.
Common issues
Model gives identical outputs for every promptTemperature 0/greedy with over-fitting or collapsed output space
Raise temperature, verify sampling path, and check the prompt is actually reaching the model.
Quality drops after switching modelsDifferent tokenizer/template shifting the intended task
Port the exact chat template/system prompt; re-tune decoding on the new model.
Latency spikes under burst trafficAutoregressive generation serializes per token; concurrent fans multiply memory
Batch requests, quantize, and use smaller context plus streaming.
Debugging tips
- Reproduce a published demo with a fixed seed before changing anything.
- Compare same prompt across temperatures — variance tells you about model uncertainty, not bugs.
- Log the exact input tokens and system prompt; most 'model behavior' mysteries are prompt mysteries.
- Use a held-out checklist of hard cases to catch regressions each release.
Interview checkpoint
Quick quiz
A generative model's training objective is fundamentally about:
LLMs and diffusion models use the same exact inference procedure.