# Variational autoencoder (VAE)

> Canonical: https://skillalmanac.com/glossary/variational-autoencoder | Last verified: 2026-11-25 | Index status: index-eligible

A variational autoencoder encodes input as a distribution over hidden values and decodes samples back into data. IBM describes it as creating new data in the form of variations of the input data it was trained on.

Also called: VAE, VAEs, VAE model, variational auto-encoder, variational autoencoders.

## In plain language

A plain autoencoder squeezes a picture into a short note and redraws it. A variational autoencoder squeezes it into a range of possible notes instead of one fixed note, so you can pick a new note from that range and ask the network to draw something it has not seen. That makes it useful for generating variations, cleaning up noisy data and spotting oddities.

## Technical definition

In a common Gaussian VAE formulation, the encoder outputs a mean and standard deviation for each latent dimension, and the decoder reconstructs input from a sampled latent value. IBM explains that a reparameterization step draws a random value from a normal distribution and combines it with the mean and standard deviation, so gradient descent can still train the network. In that Gaussian formulation, a KL divergence term regularizes the approximate posterior towards a chosen normal prior. Other variational families and priors are possible; the Gaussian example is not the definition of every VAE. Kingma and Welling (arXiv 1312.6114, submitted December 2013) introduced the underlying stochastic variational inference algorithm.

## How it shows up when you use agents

You do not usually meet a VAE while running Claude Code, Codex or Cursor, because those tools use finished language models. It matters when your work touches images or other generated media. The Hugging Face Diffusers documentation says the Stable Diffusion pipeline has three separate pretrained models, and one of them, the VAE, decodes the compressed latent representation back into an image. That describes the documented Stable Diffusion setup, not every local image generator.

The other place it appears is a data task. A coding agent can write a short VAE training script if you ask for one. If you ask for "a VAE for anomaly detection" without naming the data, the split and the size of the latent space, the agent will choose defaults you cannot judge. Ask it to state those choices first, and check the train and test files for leakage before you read any reconstruction result.

What breaks when this is misunderstood: people treat a clean reconstruction as proof the latent space is useful, or assume the VAE is the part that follows a text prompt. A next step is to decide what you want the latent values for, and test that use directly. See [Autoencoder](/glossary/autoencoder) for the non-probabilistic form and [Latent space](/glossary/latent-space) for the compressed representation itself.

## Common confusions

- **Autoencoder versus variational autoencoder.** According to IBM, most autoencoders are deterministic and encode one vector, while a VAE is probabilistic. IBM says many applications discard the decoder after training, not that most autoencoder architectures do. Reconstruction and denoising applications retain it, while a generative VAE uses its decoder for sampling.
- **VAE versus diffusion model.** A VAE decodes a latent value from a distribution. A [diffusion model](/glossary/diffusion-model) removes noise over many steps. In the Diffusers description of Stable Diffusion they are separate components that work together.
- **Reconstruction versus generation.** Rebuilding an input is the training task. Generating something new means sampling from the learned distribution, which is what the KL divergence term is there to support.
- **Myth: a VAE understands its data.** IBM describes a VAE as creating variations of the input data it was trained on. See [Generative model](/glossary/generative-model).

## Worked examples in this catalogue

### [data-analysis-eda](https://skillalmanac.com/skills/skill-almanac/data-analysis-eda)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.

Why it exercises the concept: Looking at a dataset before any model is trained is the step that comes before building a VAE. The catalogue has no skill that trains one, so this is a contrast case.

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill checks train, validation and test files for duplicates, shared groups, time and label leakage and prints JSON.

Why it exercises the concept: A VAE scored on rows it has already seen can look better than it is. This checks the split before you trust any reconstruction result. It does not train or run a VAE.

### [imagegen](https://skillalmanac.com/skills/openai/imagegen)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Generates or edits raster images such as mockups, textures and illustrations.

Why it exercises the concept: Image generators are a place a VAE can sit inside a larger system, as in the Stable Diffusion pipeline the Diffusers docs describe. This skill calls a hosted generator and does not train or expose a VAE.

### [Self-Hosting an AI Agent: What You Take On](https://skillalmanac.com/learn/self-hosted-ai-agent-considerations)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide explains that weights, cache and overhead compete for memory when you run a model yourself, and that the fit should be worked out before downloading.

Why it exercises the concept: In a local Stable Diffusion pipeline, a VAE can be one of several loaded models, so the same memory-fit question applies. The guide is written about language models.

## Related terms

- [Autoencoder](https://skillalmanac.com/glossary/autoencoder.md)
- [Generative model](https://skillalmanac.com/glossary/generative-model.md)
- [Latent space](https://skillalmanac.com/glossary/latent-space.md)
- [Diffusion model](https://skillalmanac.com/glossary/diffusion-model.md)
- [Unsupervised learning](https://skillalmanac.com/glossary/unsupervised-learning.md)
- [Neural network](https://skillalmanac.com/glossary/neural-network.md)

## Sources

- [What is a variational autoencoder?](https://www.ibm.com/think/topics/variational-autoencoder), IBM (accessed 2026-11-24)
- [Auto-Encoding Variational Bayes (Kingma and Welling)](https://arxiv.org/abs/1312.6114), arXiv (accessed 2026-11-24)
- [Understanding pipelines, models and schedulers](https://huggingface.co/docs/diffusers/en/using-diffusers/write_own_pipeline), Hugging Face (Diffusers documentation) (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
