No history yet

Introduction to Generative Models

Creating Something from Nothing

At its heart, artificial intelligence can learn from data. A generative model is a type of AI that takes this a step further: it learns the underlying patterns in a set of data so well that it can create new, original data that's similar to what it was trained on.

Think of it like a musician who listens to hundreds of classical symphonies. After a while, they don't just recognize the music; they understand the rules, structures, and styles that define it. A generative model does the same with data, allowing it to compose its own original symphony, paint a new portrait, or write a new paragraph.

Lesson image

The main purpose of these models is creation. They are the engines behind AI art generators, text-to-speech synthesizers, and tools that can write code or music. They generate content that is plausible and new, not just a copy of something that already exists.

Two Sides of the AI Coin

To understand what makes generative models special, it helps to compare them with their counterparts: discriminative models. Most of the AI we used to encounter daily, like spam filters or image classifiers, were discriminative.

A simple way to think about the difference is this: an artist versus an art critic.

An artist learns what cats look like and then paints a brand-new cat that has never existed before. This is a generative task.

An art critic looks at a painting and says, "Yes, that's a cat," or "No, that's a dog." This is a discriminative task. The critic isn't creating anything new; it's classifying what it sees.

Generative models learn the distribution of data to create new samples. Discriminative models learn the boundary between different classes of data to make predictions.

Mathematically, a generative model learns the joint probability distribution P(X,Y)P(X, Y), which means it understands how features XX and labels YY occur together. This allows it to generate new (X,Y)(X, Y) pairs. A discriminative model, on the other hand, learns the conditional probability P(YX)P(Y|X), which is just the probability of label YY given feature XX. It can only classify, not create.

FeatureGenerative ModelDiscriminative Model
GoalCreate new data samplesClassify or predict a label for given data
AnalogyThe artistThe art critic
OutputA new image, text, or soundA label or a category (e.g., "spam")
ExampleCreating a realistic photo of a personIdentifying if a photo contains a person

Three Ways to Create

Generative models aren't all the same. Different types have unique ways of learning and creating. Let's look at three of the most common approaches used in graphics generation.

GANs

noun

Stands for Generative Adversarial Networks. These models use a competitive process between two neural networks to generate high-quality, realistic data.

GANs work like a game between a counterfeiter and a detective. The counterfeiter (the generator) creates fake images and tries to make them look real. The detective (the discriminator) examines images—some real, some fake—and tries to spot the forgeries. As the game continues, the counterfeiter gets better at making fakes, and the detective gets better at spotting them. Eventually, the generator becomes so skilled that its creations are nearly indistinguishable from reality.

VAEs

noun

Stands for Variational Autoencoders. These models learn a compressed, simplified representation of data, which they can then use to generate new variations.

Imagine summarizing a complex book into a few key bullet points. That's what the first half of a VAE, the encoder, does. It takes an image and compresses it into a small set of essential features—its "essence." The second half, the decoder, then takes these bullet points and reconstructs the original book. By tweaking the bullet points before decoding, the VAE can generate a new image that is similar to the original but with slight, creative variations.

Diffusion Models

noun

These models work by systematically adding noise to data and then learning how to reverse the process to generate new, clean data from pure noise.

Diffusion models take a different approach. Think of a clear photograph. The model starts by gradually adding random noise, step by step, until the original image is completely unrecognizable static. While doing this, it carefully learns how to reverse each step. Once trained, it can start with a screen full of pure noise and apply its learned reversal process, step by step, to sculpt that static into a brand-new, coherent image. It's like a sculptor who sees a finished statue inside a block of marble and knows exactly which pieces to chip away.

Now that you have an idea of what generative models are and the different flavors they come in, let's test your knowledge.