Introduction
Who is this course for?
This course is the material I would have liked to find when I started getting interested in generative models (back in 2017).
For people with an engineering background, exploring the Machine Learning literature can feel intimidating. Algebra, calculus, statistics, etc., are subjects taught in the first years of a bachelor's degree, and their details tend to be forgotten if you don't keep practicing them in later years. As a result, concepts like ELBO optimization, density transformation, or optimal transport can seem harder than they actually are.
This course is aimed at anyone who identifies with this situation, has at least a minimal technical background, and, above all, is interested in understanding at a lower level how these models work. My goal is to walk you through learning the underlying concepts while also enabling you use them from a practical standpoint. That's why, in every chapter, you'll find code to reinforce your understanding of the explanations and to let you experiment on your own.
Before we start, two things to clarify:
-
If you're looking for material that goes deep into statistics, calculus, or probability, this isn't the place. On the internet you can find plenty of high-quality content better than these notes.
-
I've tried to keep a visually appealing aesthetic so this is a resource you'll want to come back to, but it's important to note that understanding and consolidating knowledge takes time.
"Learning is not supposed to be fun. It doesn't have to be actively not fun either, but the primary feeling should be that of effort." — Andrej Karpathy
Generative AI

As you can see in the figure, within the broader landscape of artificial intelligence, generative AI covers methods and techniques capable of generating new data samples.
From a probabilistic point of view, we fit a model to the training distribution and then sample from the learned distribution .

This process applies to a variety of domains. Below are some examples you're probably already familiar with.
Image generation
Nano Banana (Google), GPT Image 2 (OpenAI), DALL·E, Stable Diffusion, Adobe Firefly, Midjourney, FLUX…

Text / code generation
ChatGPT, Claude, Gemini, Grok, Mixtral…

Audio generation
Suno, ElevenLabs, WaveNet, VALL-E, Stable Audio, Udio…

Conditional generative models
We generally want to control what gets generated. That's why conditional generative models are used, in the form . Some examples:
- = text, = image: a text-to-image model. Example: Nano Banana.
- = image, = text: an image-to-text model. Example: give ChatGPT an image and ask it to describe it.
- = image, = image: an image-to-image model. Example: image editing in Adobe Firefly.
- = audio, = text: a speech-to-text model. Example: Whisper, or any voice dictation.
- = text, = audio: a text-to-speech model. Example: ElevenLabs TTS.
- = text, = text: a sequence-to-sequence model. Example: translators (text generation models would also fall under this category).
Other applications
The nice thing about modeling a distribution is that it doesn't just let you generate data, but a lot of other things too.
Density estimation
This consists of evaluating the density that the model assigns to a data sample, i.e., computing . This is useful for problems such as data compression, anomaly detection, classification, model comparison, etc.
The simplest approach to density estimation is to use kernel density estimation or KDE. However, KDE runs into limitations in high-dimensional spaces (the curse of dimensionality), where the density of the data becomes extremely sparse.
Modern generative networks mitigate this limitation by learning compact, complex representations that make it possible to estimate or model density in a much more efficient and scalable way for high-dimensional data such as images, audio, or text.
Data imputation
This consists of "filling in" missing values in a data vector or matrix. For example, a simple way to fill in missing data in tabular data is to use the mean value of each column (mean imputation).
We can generalize this by learning a joint model over all the variables and, for each incomplete record, sampling the missing values conditioned on the observed ones : . This is called multiple imputation.

A generative model can be used to fill in more complex types of data, such as masked pixels in an image.
Representation learning
Some types of generative models have latent variables , which can be understood as the causes that generated the observed data . These variables generally reduce the dimensionality of the data and make it possible to discover patterns / useful representations.

Interpolation in the latent space
The latent space is where the latent variables live. It can be understood as the space into which models compress the data.
One of the most interesting capabilities of certain latent-variable models is the ability to generate samples with certain desired properties by interpolating between existing data points in the latent space.
In the following example we reduce the latent space to two dimensions: each chair is a point on a plane. We pick four samples and interpolate their coordinates. Decoding the intermediate points gives us representations that combine properties of the selected samples.

Data compression
Models that can assign high probability to frequently occurring data and low probability to rare data can be used for data compression, since they can assign shorter codes to the most common elements. Compression is a beautiful field that overlaps directly with Information Theory. We'll cover some of this in the Variational Autoencoders chapter.
Timeline
This timeline brings together a selection of particularly influential works in the evolution of generative models. Don't worry if you don't understand what they're about right now — it's a reference you can come back to later.
We'll also cover foundational models. However, the literature is much broader than that, so I've decided to include here works related to generative models, along with some architectures and training techniques (such as CLIP, LoRA, RLHF, or DPO) that, while not generative themselves, have been key to their evolution.
Evolution of generative models
26 papers visible.