Generative Deep LearningIntroductionGenerative deep learning concerns models that learn the statistical structure of data and use it to produce new samples. Unlike a conventional classifier, which estimates a label from an input, a generative model attempts to represent a data distribution such as images, text, audio, molecular structures, or time series. Its output may be novel, but useful generation requires more than novelty: the output should be coherent, relevant, controllable, safe, and appropriate for its intended use. Four model families dominate contemporary practice: autoregressive models, variational autoencoders (VAEs), generative adversarial networks (GANs), and diffusion models. They differ in how they represent probability distributions, how they generate samples, what kinds of errors they produce, and how readily they can be controlled. This chapter develops a comparative understanding of these families and examines evaluation, deployment, safety, and intellectual-property risks. Learning ObjectivesBy the end of this chapter, students should be able to: - Explain the probabilistic foundations of generative modelling.
- Compare autoregressive models, VAEs, GANs, and diffusion models.
- Interpret the principal training objectives and sampling procedures of each family.
- Select evaluation methods appropriate to a generative task.
- Design strategies for quality, controllability, monitoring, and human oversight.
- Analyse safety, privacy, bias, provenance, copyright, and intellectual-property risks.
1. Probabilistic FoundationsLet a dataset consist of observations x drawn from an unknown data distribution pdata(x). A generative model with parameters θ defines an approximation pθ(x). Training seeks parameters that make model samples statistically and semantically similar to the data, while avoiding undesirable memorisation. For a sequence x1:T, the chain rule gives: p(x1:T) = ∏t=1T p(xt | x1:t-1) Here x1:t-1 denotes all preceding elements. This identity is exact; an autoregressive model approximates the individual conditional distributions. In contrast, latent-variable models introduce an unobserved representation z, and adversarial models may learn a generator without explicitly evaluating pθ(x). Two related but distinct goals are important: - Density estimation: assigning probabilities or likelihoods to observations.
- Sample generation: producing realistic new observations.
High likelihood does not always imply high perceptual quality, and visually attractive samples do not necessarily provide reliable likelihood estimates. Therefore model selection must use task-specific and human-centred evidence. 2. Autoregressive ModelsPrincipleAn autoregressive model generates one element at a time. For text, an element is usually a token; for audio it may be a waveform sample or codec token; for images it may be a pixel, patch, or discrete visual token. At time t, the model predicts xt conditioned on the prefix x1:t-1. A neural network, commonly a transformer, parameterises: p_θ(xt | x1:t-1) The training objective is maximum likelihood, equivalently minimisation of negative log-likelihood: LNLL(θ) = -∑t=1T log p_θ(xt | x1:t-1) The logarithm is natural unless otherwise specified. For token models, the loss is measured in nats per sequence; dividing by the number of tokens gives average negative log-likelihood. If logarithms base 2 are used, the unit is bits. During training, teacher forcing supplies the true preceding tokens. During generation, the model must condition on its own previous outputs. This difference is called exposure bias. Sampling can be greedy, stochastic, or restricted by temperature and top-k/top-p rules. Temperature τ > 0 rescales logits before softmax: pi(τ) = exp(li / τ) / ∑j exp(lj / τ) Here li is the logit for candidate i. Lower temperature concentrates probability on high-scoring candidates; higher temperature increases diversity. Temperature changes the sampling distribution but does not retrain the model. Strengths and limitationsAutoregressive models provide principled likelihoods, excellent sequence coherence, and flexible conditioning. They are particularly effective for language, code, music tokens, and structured sequences. Their main limitation is sequential sampling: generating T elements generally requires many dependent prediction steps. Errors can also accumulate, and likelihood may reward statistically common but bland outputs. Modern language models add conditioning through prompts, retrieved documents, tool calls, system policies, or fine-tuning. Such mechanisms improve usefulness but do not guarantee factuality: a model predicts plausible continuations, not truth itself. 3. Variational AutoencodersLatent-variable formulationA VAE assumes that observations are generated from a latent variable. The prior is commonly p(z) = N(0,I), and a decoder defines p_θ(x|z). An encoder, or inference model, approximates the posterior with q_φ(z|x). Direct optimisation of log p_θ(x) is difficult because the exact posterior is often intractable. Using the evidence lower bound (ELBO): log p_θ(x) ≥ Eq_φ(z|x)[log p_θ(x|z)] − DKL(q_φ(z|x) || p(z)) The training objective commonly minimises the negative ELBO: LVAE = −Eq_φ(z|x)[log p_θ(x|z)] + β DKL(q_φ(z|x) || p(z)) The reconstruction term measures how well the decoder explains the observation. The Kullback–Leibler divergence regularises the approximate posterior toward the prior. β=1 gives the standard ELBO; other values deliberately change the trade-off between reconstruction and latent regularity. For a diagonal Gaussian encoder, the reparameterisation trick writes: z = μ_φ(x) + σ_φ(x) ⊙ ε, ε ∼ N(0,I) The symbol ⊙ denotes element-wise multiplication. This formulation permits gradient-based optimisation through stochastic sampling. InterpretationVAEs offer a comparatively smooth latent space. Interpolating between latent vectors often produces gradual semantic transitions, which is valuable for design, anomaly detection, representation learning, and controlled synthesis. Their weaknesses include blurry outputs when the likelihood model or reconstruction loss is mismatched to perception, and posterior collapse, in which the decoder ignores z and the encoder approaches the prior. Mitigations include KL annealing, decoder weakening, free-bits objectives, richer priors, hierarchical latent variables, and perceptual or adversarial reconstruction terms. These methods alter optimisation behaviour and may sacrifice the clean probabilistic interpretation of the original ELBO. 4. Generative Adversarial NetworksAdversarial gameA GAN contains a generator G that maps noise z ∼ p(z) to a synthetic sample G(z), and a discriminator D that estimates whether an input is real. The original minimax objective is: minG maxD V(D,G) = Ex∼pdata[log D(x)] + Ez∼p(z)[log(1 − D(G(z)))] The discriminator maximises the objective, while the generator minimises it. In practice, the non-saturating generator loss is often used: LG = −Ez∼p(z)[log D(G(z))] The generator and discriminator are trained alternately. At the ideal theoretical equilibrium, the generated distribution equals the data distribution and the discriminator cannot distinguish the two better than chance. This result assumes sufficient model capacity, successful optimisation, and an idealised equilibrium—conditions rarely fully achieved in practice. Practical behaviourGANs can generate sharp, visually convincing images and support conditional generation through class labels, text, segmentation maps, or other signals. However, adversarial training is sensitive to architecture, learning rates, regularisation, and update balance. Mode collapse occurs when the generator produces limited varieties of samples. A GAN may also generate visually plausible but structurally incorrect content. Common remedies include Wasserstein-style objectives, gradient penalties, spectral normalisation, minibatch statistics, progressive or multi-scale training, and explicit diversity regularisation. These techniques improve stability but do not eliminate the need for evaluation. 5. Diffusion ModelsForward and reverse processesA diffusion model gradually corrupts data with noise and learns to reverse that process. A common forward process is: q(xt | xt−1) = N(√(1−βt)xt−1, βt I) where t=1,...,T, 0<βt<1 is a variance schedule, I is the identity matrix, and the variables are scaled consistently, often after data normalisation. The closed form is: q(xt | x0) = N(√α̅t x0, (1−α̅t)I) where αt=1−βt and α̅t=∏s=1t αs. The model learns a denoiser, often parameterised to predict the added noise ε: Lsimple = Et,x0,ε[||ε − ε_θ(xt,t)||22] Here ε∼N(0,I), xt=√α̅t x0+√(1−α̅t)ε, and ||·||22 is squared Euclidean error. Sampling begins with noise and applies a learned reverse transition repeatedly. Conditioning and guidanceText-to-image diffusion models condition the denoiser on an embedding c. Classifier-free guidance combines conditional and unconditional predictions: εguided = ε_θ(xt,t,∅) + w[ε_θ(xt,t,c) − ε_θ(xt,t,∅)] Here ∅ denotes no condition and w≥0 is a guidance scale. Increasing w often improves prompt adherence but may reduce diversity, introduce artefacts, or amplify biases. Guidance is therefore a controllability–quality trade-off, not a universally beneficial adjustment. Diffusion models generally offer high perceptual quality, strong conditional control, and better coverage than many GANs. Their disadvantages are computationally expensive sampling, substantial training costs, and possible reproduction of training images, styles, or harmful associations. 6. Comparative EvaluationNo single metric captures generative quality. Evaluation should combine distributional, task-specific, human, safety, and operational evidence. | Family | Main training idea | Major strengths | Typical limitations |
|---|
| Autoregressive | Factorised conditional likelihood | Coherent sequences; explicit likelihood | Slow sequential sampling; exposure bias | | VAE | ELBO with latent variable | Smooth latent space; efficient encoding | Blur; posterior collapse | | GAN | Generator–discriminator game | Sharp samples; fast generation after training | Instability; mode collapse | | Diffusion | Learned denoising reverse process | High quality; broad coverage; conditioning | Slow sampling; high compute cost |
Quantitative metricsFor language, perplexity is derived from average log loss: Perplexity = exp(−(1/N)∑i=1N log p_θ(xi|x<i)) N is the number of evaluated tokens. Perplexity is meaningful for comparing models on the same tokenisation and dataset, but lower perplexity does not guarantee factual or stylistically desirable output. For images, Fréchet Inception Distance (FID) compares feature distributions. If real and generated features have means μr, μg and covariances Σr, Σg, then: FID = ||μr−μg||22 + Tr(Σr + Σg − 2(ΣrΣg)1/2) Tr is the matrix trace. FID depends on the feature extractor, sample size, preprocessing, and domain; it is not a universal perceptual measure. Inception Score can reflect class confidence and diversity but may fail to detect memorisation or subtle defects. Useful complementary measures include precision and recall for generative distributions, nearest-neighbour and membership-inference tests for memorisation, calibration and factuality tests for text, task success for controlled generation, and expert review for high-risk domains. Human evaluationA defensible protocol defines the population, sampling procedure, rating rubric, and inter-rater reliability in advance. Reviewers may score realism, relevance, coherence, originality, harm, or actionability. Pairwise preference tests are often easier to interpret than absolute scores. Evaluators should be blind to model identity, and prompts should include ordinary, difficult, adversarial, and safety-sensitive cases. 7. Quality and Controllability in PracticeA production system should separate three questions: - Can it generate?—technical functionality and latency.
- Should this output be accepted?—quality, safety, and policy checks.
- Can users direct it reliably?—controllability and transparency.
Control can be introduced through conditioning, retrieval, fine-tuning, adapters, structured decoding, constrained generation, planning, and post-generation verification. Control signals should be tested for conflicts: a prompt may request a particular style while a policy prohibits impersonation or disclosure of private information. A practical quality pipeline includes: - representative validation data separated from training data;
- automated checks for syntax, toxicity, privacy leakage, and task constraints;
- human review for ambiguous or high-impact outputs;
- logging of prompts, model versions, controls, and decisions, subject to privacy law;
- drift monitoring after deployment;
- a feedback process that distinguishes model defects from user misuse.
For stochastic systems, report confidence intervals or uncertainty across repeated runs rather than a single impressive sample. Benchmark contamination must also be investigated: a model may appear capable because evaluation examples were present in training data. 8. Safety, Governance, and Intellectual PropertyGenerative systems can produce misinformation, discriminatory content, malware instructions, non-consensual intimate imagery, unsafe medical advice, and realistic impersonation. Risk management should be proportionate to foreseeable harm and deployment context. Safety controlsA layered approach is stronger than a single filter: - dataset documentation and removal of prohibited or unlawfully obtained material;
- access controls and rate limits;
- input and output classifiers;
- refusal and redirection policies;
- provenance signals such as metadata or watermarking where technically appropriate;
- red-team testing and incident response;
- human approval for consequential decisions;
- post-deployment monitoring and model rollback.
Filters have false positives and false negatives. They should therefore be evaluated by subgroup, language, modality, and attack type. Safety policies should be explicit about who decides acceptable risk and how users can appeal or report failures. Privacy and memorisationA model may reproduce training examples or reveal personal information. Testing should include canary records, extraction attempts, membership-inference analysis, and nearest-neighbour inspection. Privacy-preserving training, data minimisation, access restrictions, and removal requests reduce exposure, but no method guarantees zero leakage in every setting. Copyright and related rightsGenerative development may implicate copyright in training data, outputs, model weights, prompts, and stylistic imitation. Legal rules vary by jurisdiction and continue to evolve. Organisations should maintain dataset provenance, licences, contributor terms, and records of model versions. They should avoid presenting generated material as human-authored when disclosure is required, and they should establish review procedures for substantial similarity, trademarks, publicity rights, and confidential information. A responsible policy distinguishes technical capability from legal permission. “The model can generate it” is not evidence that the organisation may use, distribute, or commercialise it. 9. Illustrative Case: Synthetic Industrial Inspection ImagesBackgroundA manufacturer has limited labelled images of rare surface defects. It proposes a generative model to create additional training images for a visual-inspection classifier. ProblemThe defect classes are imbalanced, real images contain confidential plant information, and synthetic images that look realistic may still contain physically impossible textures. A classifier trained on them could become confidently wrong. AnalysisThe team compares a conditional GAN and a diffusion model. The GAN produces images quickly but repeats a small number of defect patterns. The diffusion model offers greater variation but requires more computation. Neither metric alone establishes usefulness: FID may improve while defect geometry remains incorrect. Approach and solutionThe team uses access-controlled real images, removes irrelevant identifying information, and conditions generation on defect type, location, and severity. Industrial engineers define physical validity rules. Generated images are screened using image similarity, defect-shape checks, and expert review. The classifier is trained with mixtures of real and synthetic data, while a holdout set contains only newly collected real images. Performance is reported by defect class, with confidence intervals and false-negative rates. Synthetic data is retained only when it improves performance on the real holdout set. The organisation records provenance, model version, prompts or conditions, reviewer decisions, and known limitations. Outcome and learning pointsThe diffusion model improves recall for two rare classes, but synthetic images alone reduce performance because they omit lighting and camera variation. The final system uses synthetic data as augmentation rather than replacement. The case demonstrates that generative quality is ultimately task-relative, and that domain validation, not visual appeal, determines operational value. 10. Contemporary Directions and Best PracticesCurrent research includes multimodal foundation models, latent diffusion, flow and consistency models for faster sampling, controllable image and video generation, retrieval-augmented generation, neural audio and 3D generation, synthetic-data evaluation, and privacy-preserving or provenance-aware training. These developments reduce some bottlenecks while creating new ones, especially in compute demand, data governance, and evaluation reliability. Best practice is to: - Define the intended task, users, failure costs, and prohibited uses before model selection.
- Choose a model family according to modality, latency, likelihood needs, controllability, and compute budget.
- Keep training, tuning, and evaluation data strictly separated.
- Measure both quality and coverage, and test for memorisation.
- Use human review where errors can cause material harm.
- Document data sources, licences, limitations, evaluation conditions, and model changes.
- Treat prompts, generated outputs, and logs as potentially sensitive information.
- Monitor deployed systems for drift, abuse, bias, and newly discovered failure modes.
- Provide users with meaningful disclosure about generation and uncertainty.
- Prefer reversible deployment, staged access, and incident response over unrestricted release.
Chapter SummaryGenerative deep learning models learn structures from data and produce new samples. Autoregressive models factorise distributions and generate sequentially, offering strong sequence coherence at the cost of sampling latency. VAEs optimise an ELBO and provide useful, smooth latent representations, but may produce blurred outputs or suffer posterior collapse. GANs use an adversarial game to generate sharp samples, yet are vulnerable to instability and mode collapse. Diffusion models learn iterative denoising and currently provide strong quality and conditioning, although sampling and training can be computationally expensive. Evaluation must combine likelihood or distributional metrics with task performance, human judgement, safety testing, privacy analysis, and operational monitoring. Controllability involves conditioning, constrained decoding, retrieval, fine-tuning, and verification, but stronger guidance can reduce diversity or amplify bias. Responsible deployment requires layered safety controls, provenance and documentation, privacy protection, human oversight, and careful analysis of copyright and other intellectual-property rights. The central professional principle is that a convincing sample is not necessarily a correct, safe, lawful, or useful one. Key TermsGenerative model: A model that represents data structure and produces new samples. Autoregressive model: A model that predicts each element conditional on preceding elements. Teacher forcing: Training a sequence model using the true previous elements as inputs. Exposure bias: The mismatch between training with true prefixes and generation with model-produced prefixes. Variational autoencoder: A latent-variable generative model trained using an evidence lower bound. ELBO: A tractable lower bound on the log marginal likelihood. Reparameterisation trick: A transformation that enables gradients through stochastic latent sampling. Posterior collapse: A VAE failure in which the decoder largely ignores its latent variable. Generative adversarial network: A generator–discriminator framework trained through competition. Mode collapse: Production of insufficiently diverse outputs by a generative model. Diffusion model: A model trained to reverse a gradual data-corruption process. Classifier-free guidance: A conditioning method that combines conditional and unconditional denoising predictions. Likelihood: The probability assigned by a model to observed data. Perplexity: The exponentiated average negative log-likelihood for a sequence model. FID: A feature-distribution distance commonly used for image-generation evaluation. Controllability: The extent to which users can reliably direct generated outputs. Memorisation: Reproduction or retention of specific training examples or sensitive information. Provenance: Evidence about the origin, transformations, and ownership of data or outputs. Red teaming: Deliberate testing designed to expose failures, misuse, or vulnerabilities. Review QuestionsShort Answer Questions- What is the difference between density estimation and sample generation?
- Explain exposure bias in autoregressive models.
- What two terms constitute the standard VAE objective?
- Define mode collapse in a GAN.
- Why is FID insufficient as the sole measure of image-generation quality?
Long Answer Questions- Compare autoregressive models, VAEs, GANs, and diffusion models in terms of objective, sampling, strengths, and limitations.
- Derive and interpret the VAE negative ELBO, defining each term and explaining the role of the KL divergence.
- Explain the diffusion forward process, denoising objective, and classifier-free guidance.
- Design an evaluation framework for a text-to-image system used in a professional organisation.
- Discuss privacy, copyright, provenance, and safety governance for a generative AI product.
Analytical / Application Questions- An organisation needs fast, diverse synthetic images for a rare medical condition. Which model family or combination would you investigate, and what evidence would determine deployment?
- A language model has low perplexity but frequently produces unsupported claims. Analyse why this can occur and propose an evaluation and mitigation plan.
- A GAN produces visually excellent samples but fails on rare categories. Diagnose the likely problem and design tests and interventions to improve coverage.
Multiple Choice Questions with AnswersQuestion 1Which objective is directly associated with an autoregressive language model? A. Predicting each token conditional on preceding tokens B. Minimising only the discriminator's classification error C. Matching a fixed Gaussian posterior without reconstruction D. Adding noise without learning a reverse process Correct Answer: A. Predicting each token conditional on preceding tokens Question 2In a standard VAE, the KL-divergence term primarily regularises: A. The discriminator toward uniform predictions B. The approximate posterior toward the prior C. The sampling temperature toward zero D. The FID feature extractor toward real images Correct Answer: B. The approximate posterior toward the prior Question 3What is a common symptom of GAN mode collapse? A. The model assigns exact probabilities to every training example B. The generator produces insufficiently diverse samples C. The encoder cannot use the reparameterisation trick D. The diffusion schedule has no variance terms Correct Answer: B. The generator produces insufficiently diverse samples Question 4In a diffusion model, the forward process generally: A. Removes noise from a random image in one step B. Gradually adds noise to data according to a schedule C. Uses a discriminator to classify real and fake samples D. Predicts the next token in a sequence Correct Answer: B. Gradually adds noise to data according to a schedule Question 5Increasing classifier-free guidance generally creates which trade-off? A. More prompt adherence may occur at the expense of diversity or artefacts B. Likelihood becomes exact for every data distribution C. Sampling becomes independent of the conditioning input D. Training data can no longer influence the model Correct Answer: A. More prompt adherence may occur at the expense of diversity or artefacts Question 6For a token model with average negative log-likelihood equal to 2 nats per token, perplexity is approximately: A. 2 B. e², approximately 7.39 C. 10², exactly 100 D. 1/e², approximately 0.14 Correct Answer: B. e², approximately 7.39 Question 7Why should FID not be treated as a universal measure of generative quality? A. It cannot be calculated using feature representations B. It depends on the feature extractor, preprocessing, and domain C. It measures only text-token likelihood D. It is defined only for autoregressive models Correct Answer: B. It depends on the feature extractor, preprocessing, and domain Question 8Which practice best tests whether synthetic industrial images are useful for inspection? A. Selecting the model with the most attractive individual samples B. Evaluating a classifier on a holdout set containing newly collected real images C. Removing all real images from evaluation D. Using only training-set reconstruction error Correct Answer: B. Evaluating a classifier on a holdout set containing newly collected real images Question 9Which statement about generated content and intellectual property is most defensible? A. Technical ability to generate content automatically establishes legal permission to use it B. Legal implications vary, so provenance, licences, and review procedures are needed C. Generated content can never resemble protected material D. A watermark alone resolves all ownership questions Correct Answer: B. Legal implications vary, so provenance, licences, and review procedures are needed Question 10Why are layered safety controls preferable to a single output filter? A. Every individual layer is guaranteed to have zero false positives B. Different layers address data, access, generation, monitoring, and incident risks C. They eliminate the need for human oversight in high-risk uses D. They make evaluation unnecessary Correct Answer: B. Different layers address data, access, generation, monitoring, and incident risks
|