HSR Sector 6 · Bangalore +91 96110 27980 Mon–Sat · 09:30–20:30
Chapter 3 of 25 — Generative AI Fundamentals
beginner Chapter 3 of 25

Types of Generative AI Models: LLMs, GANs, VAEs, Diffusion and Foundation Models

By Vikas Swami, CCIE #22239 | Updated Mar 2026 | Free Course

What Are the Main Types of Generative AI Models?

The main types of generative AI models include autoregressive models, generative adversarial networks (GANs), variational autoencoders (VAEs) and diffusion models. Many large language models (LLMs) generate text autoregressively, while foundation models are defined by broad pretraining and reuse across tasks. The labels overlap: a single system can be an autoregressive model, an LLM and a foundation model.

A generative AI map shows five commonly discussed groups and marks autoregression as a common generation method for LLMs.
The labels overlap because they can describe a model's purpose, training objective or generation method.

Generative modelling starts with examples of data, such as sentences, photographs or audio clips. The aim is to learn patterns that let the model produce new samples, often under a condition such as a text prompt, a class label or an input image. Some methods assign a probability to each possible output. Others learn how to produce samples without giving you a practical way to calculate the probability of an individual sample. Both qualify as generative models.

LabelWhat the label describesHow a sample is producedExample output
Autoregressive modelA probability distribution factored into sequential predictionsSample the next token or value using the prefix produced so farText, code or audio tokens
LLMA large model trained primarily to process languageA common generative design predicts one token at a timeAn answer, summary or code snippet
GANA training setup with a generator and a discriminatorMap a random vector to an output with the trained generatorA synthetic image
VAEA probabilistic latent-variable model with a particular training objectiveSample a latent vector, then decode itA new sample or a reconstruction
Diffusion modelA model trained to reverse a process that adds noiseStart with noise and apply a sequence of reverse updatesAn image, audio clip or video
Foundation modelA broadly pretrained model that can be adapted to many tasksUse the underlying generation mechanism, if the model is generativeVaries by model and application

Keep three questions separate: What data does the model handle? How does it generate a sample? How broadly can its pretrained capabilities be reused? For example, an image generator could use a GAN or diffusion, and a VAE could be a component inside a diffusion system. A transformer describes a network architecture, so seeing that word alone does not tell you which training objective or sampling procedure a model uses.

How Do LLMs and Autoregressive Models Generate Text?

Many generative large language models, including GPT-style models, use a decoder-only transformer. A tokenizer first converts text into a sequence of token IDs. Tokens can represent whole words, word fragments, punctuation or other units. The transformer turns the prefix into contextual representations and produces a vector of scores, called logits, with one score per vocabulary entry at each position.

During training, the usual objective is next-token prediction. A causal attention mask prevents each position from looking at future tokens. Because the correct prefix is already present in the training sequence, the model can compute losses for many positions in one forward pass. The loss adds or averages the negative log probabilities of the actual next tokens. During generation, the actual continuation is unknown: the decoder selects or samples a token, appends it to the prefix and repeats until a stop condition is met.

The sequence probability is a product of conditional probabilities. For a continuation x1, x2, ..., xT and a prompt c, the first factor is P(x1 | c), the second is P(x2 | c, x1), and each remaining factor conditions on all earlier tokens in the continuation. This factorisation also works for other ordered data. An audio system can, for example, predict tokens from an audio codec and then decode the token sequence into a waveform.

Worked example: From logits to a two-token probability

Suppose a toy vocabulary has three entries: train, bus and flight. After the prompt She travelled by, their logits are [2, 1, 0]. Softmax divides each exponentiated logit by the sum of all three exponentials. For train, that gives exp(2) / (exp(2) + exp(1) + exp(0)), or about 0.665. The other probabilities are about 0.245 and 0.090.

Now assume the model gives bus a probability of 0.20 at the next position after train has been appended. Under unrestricted sampling, the probability that the continuation starts with the exact token sequence [train, bus] is about 0.665 × 0.20 = 0.133. A different first token would produce a different prefix and potentially a different distribution at the second step. This is a numerical example, so the toy vocabulary need not produce natural sentences.

import torch

vocab = ["train", "bus", "flight"]
logits = torch.tensor([2.0, 1.0, 0.0])
probs = torch.softmax(logits, dim=-1)
print(dict(zip(vocab, [round(p, 3) for p in probs.tolist()])))

# Greedy decoding selects the highest-probability token.
greedy_id = probs.argmax().item()
print("Greedy choice:", vocab[greedy_id])

# Sampling can select any token with positive probability.
rng = torch.Generator().manual_seed(7)
sample_id = torch.multinomial(probs, 1, generator=rng).item()
print("Sampled choice:", vocab[sample_id])

# Given: P(bus | prompt, train) = 0.20.
print("Probability of prefix [train, bus]:", round(probs[0].item() * 0.20, 3))

The code replaces a full transformer with fixed logits to isolate decoding. In a real model, those logits come from a forward pass on the current prefix. Also, the largest probability here measures what the model predicts as a continuation. It provides no evidence about which vehicle anyone actually used.

How Do GANs Generate Realistic Images?

Generative adversarial networks train two neural networks together. The generator G takes a random vector z and produces a synthetic sample G(z). The discriminator D receives either a training example or a generated sample and learns to distinguish the two. A conditional GAN can also receive a label, such as an object category, to influence the kind of sample it makes.

Consider a discriminator update with a real image x and a synthetic image G(z). For the standard binary classification loss, the discriminator is trained to push D(x) toward one and D(G(z)) toward zero. A common generator loss is -log D(G(z)), averaged across generated samples. During that update, the discriminator's weights stay fixed, but gradients pass through the discriminator into the generator. This tells the generator how changes to its output affect the discriminator's score.

At generation time, a standard GAN needs only the generator. A single generator forward pass can produce a sample, which makes GANs attractive when latency matters and the output domain is well defined. Training can be difficult because the signal changes as the discriminator improves. One failure is mode collapse: several different inputs produce very similar outputs. When testing a GAN for synthetic product images, check whether it covers different product types, colours and viewpoints. A handful of sharp images can hide missing categories.

How Do VAEs Learn a Latent Space and Generate New Data?

A variational autoencoder learns to represent an input with a distribution over hidden variables, called latent variables. In a common design, an encoder reads an input x and predicts a mean vector mu and a log-variance vector logvar. The approximate posterior q(z | x) is a Gaussian with diagonal covariance. A decoder defines p(x | z), a distribution over possible outputs for a given latent vector.

Sampling is written as z = mu + exp(0.5 * logvar) * eps, where eps is sampled from a standard normal distribution and operations are elementwise. This reparameterisation keeps the random draw separate from the encoder outputs, so gradients can pass through mu and logvar. For one latent coordinate with mean 2, variance 0.25 and a noise draw -1, the standard deviation is 0.5 and the sampled coordinate is 1.5.

A standard VAE maximises an objective called the evidence lower bound, or ELBO: E_q[log p(x | z)] - KL(q(z | x) || p(z)). The first term rewards the decoder for assigning high likelihood to the observed input. The second penalises divergence from the chosen latent prior, often a standard normal. The prior gives the system a known distribution to sample from when no input example is available.

For reconstruction, encode an existing example and decode a latent representation of that example. For fresh generation, skip the encoder, draw z from the prior and decode it. This distinction matters when evaluating a VAE: strong reconstruction scores tell you how well the system preserves given inputs, while the quality and diversity of prior samples tell you how well it generates independently.

How Do Diffusion Models Generate Images, Audio and Video?

Diffusion models learn to reverse progressive corruption. For a common Gaussian formulation, training starts with a clean sample x0, picks a timestep t and constructs a noisy version directly:

xt = sqrt(alpha_bar_t) * x0 + sqrt(1 - alpha_bar_t) * eps

Here, eps is standard Gaussian noise, and alpha_bar_t is the cumulative signal retention set by the noise schedule. If it is 0.25, the clean sample is scaled by 0.5 and the noise by about 0.866. In a common training objective, a network predicts the added noise from xt, the timestep and any conditioning input. Training minimises the mean squared difference between the predicted and actual noise. Other formulations predict the clean sample or a related quantity.

At generation time, a sampler starts from noise. At each step, the network predicts what the sampler needs to compute the next, less noisy state. In text-to-image generation, text representations can condition the denoising network through cross-attention, so different prompts can push the same initial noise toward different outputs. The sampler and step count affect runtime and output quality; sampling typically requires multiple network evaluations.

Stable Diffusion is an example of latent diffusion. An autoencoder supplies a compressed image representation, the diffusion process operates in that latent space, and the decoder converts the final latent into pixels. This saves computation compared with running an equivalent process directly at full image resolution. Similar ideas apply to representations of audio and video. Sora was publicly described as using a diffusion transformer for video generation, where temporal consistency adds a challenge: objects should remain coherent across frames as they move or become partly hidden.

What Are Foundation Models and How Are They Adapted?

Foundation models are broadly pretrained models that can be adapted to a range of downstream tasks. Their pretraining often uses large, diverse datasets to learn patterns reusable across tasks. The data mix depends on the model: it may include text and code, images paired with text, or several modalities. Broad reuse is the distinguishing idea; there is no single parameter count or dataset size that by itself makes a model a foundation model.

A flow diagram shows pretraining data feeding a foundation model that is adapted for several application types.
A pretrained model can support multiple applications, with the adaptation method chosen for each task.

GPT from OpenAI, Llama from Meta, Gemini from Google and Claude from Anthropic are examples of foundation model families. Capabilities and supported inputs vary across versions, so check the specific model before designing an application. Stable Diffusion is an example from image generation: pretrained weights can support varied visual tasks and can be adapted for particular styles or domains without training an image generator from scratch.

  • Zero-shot prompting: Give an instruction without worked demonstrations. For example, ask a language model to label a customer message as billing, delivery or account access. Its weights stay fixed.
  • Few-shot prompting: Put a small set of labelled examples in the prompt. Examples can show how to handle mixed complaints or match a required output format. They affect the current context without updating weights.
  • Fine-tuning: Train on examples that represent the target task. Full fine-tuning updates the base weights. Parameter-efficient methods such as LoRA can keep the original weights fixed and train smaller sets of added parameters.

Pretraining supplies reusable capability, while the application sets the task and checks the result. For instance, a support assistant may supply current policy passages with the question at inference time. That gives the model evidence about policies that may have changed since pretraining. Fine-tuning can help with a repeated response format, but it is a poor replacement for a current policy source that the organisation can update directly.

Which Models Fit Common Generative AI Applications?

Start with the output you need, then choose how you will measure errors. A visually convincing image can still ignore part of its prompt. A fluent support reply can still cite the wrong policy. An application often needs deterministic checks or trusted inputs alongside the generator.

  • Chatbots and assistants: Use an instruction-following LLM and supply current documents when answers depend on internal policies. Test whether answers are supported by the documents and whether the assistant asks for clarification when information is missing.
  • Content generation: Use an LLM for drafts, summaries or variants of a description. For a summary, check whether each claim is supported by the source, especially names, dates, quantities and units.
  • Image and video generation: Try diffusion when prompt control and varied outputs matter. For a narrow image task with strict latency requirements, compare a trained GAN. Evaluate prompt alignment, output diversity and, for video, consistency across frames.
  • Code generation: Give a code-capable LLM interfaces, examples and constraints. Use a parser and tests to check the result. Include edge cases, because plausible code can still implement the wrong logic.
  • Data analysis and reasoning: Let an LLM propose a query or explain a table, but calculate the figures in SQL or Python. Check results against known totals and verify assumptions about filters, joins and missing values.

Use the same inputs and acceptance criteria when comparing two candidates. For example, to compare zero-shot and few-shot classification, hold out a labelled test set and count wrong labels separately from invalid output formats. Measure latency on the same request set. These checks help you tell whether the model needs better task examples, a stricter output contract or a different architecture.

Key Takeaways

  • Model labels describe different properties. An LLM can generate autoregressively and also be a foundation model.
  • Autoregressive models predict each token from the prefix, and sequence probabilities multiply the corresponding conditional probabilities.
  • GANs train a generator against a discriminator, but typically use only the generator at inference.
  • VAEs learn a probabilistic latent representation and can generate fresh samples by decoding draws from a prior.
  • Diffusion models generate samples through repeated reverse updates, sometimes in a compressed latent space.
  • Foundation models can be adapted with prompts or training. Choose the method and evaluate results against the application's actual failure modes.

Frequently Asked Questions

Are LLMs and autoregressive models the same?

Many generative LLMs are autoregressive because they predict text one token at a time from a prefix. Autoregression can also be used for audio tokens or other ordered data. LLM describes a model focused on language, while autoregressive describes how a sequence distribution is factorised and sampled.

What makes a model a foundation model?

A foundation model is pretrained broadly enough to support adaptation to a range of downstream tasks. The same base language model, for instance, might support summarisation, classification and code assistance. Model size alone is insufficient: a large model trained for a single narrow purpose does not automatically qualify.

What is the difference between a GAN and a diffusion model?

A GAN gets its training signal from a discriminator and typically produces a sample in one generator pass. A diffusion model learns to reverse a corruption process and usually generates a sample over several updates. The practical comparison depends on output quality, diversity, conditioning, training stability and inference latency for your task.

Can a VAE be part of a diffusion model?

Yes. In systems such as Stable Diffusion, a variational autoencoder maps images into a compressed latent space and decodes latents back into images. A separate denoising network learns to work in that space. For text-to-image generation, the sampler starts with latent noise and the decoder converts the final latent into an image.

Should beginners try prompting or fine-tuning first?

Start with a clear instruction and evaluate it on examples the model has not seen in the prompt. Add a few demonstrations if the model misunderstands the format or decision rule. Consider fine-tuning when recurring errors remain and you have reliable training data. If the task depends on current facts, supply those facts from a maintained source.

Ready to Master Generative AI Fundamentals?

Join 45,000+ students at Networkers Home. CCIE-certified trainers, 24x7 real lab access, and Placement Guarantee* — structured interview support until placed.

Explore Course