Variational autoencoder (VAE)
A variational autoencoder is a generative neural network that learns to compress data into a smooth, probabilistic latent space and to decode points from that space back into realistic examples.
A plain autoencoder has two halves. An encoder squeezes an input, such as an image, into a short code, and a decoder rebuilds the input from that code. It is good at compression, but its code space tends to be patchy, so a randomly chosen code rarely decodes into anything sensible. A variational autoencoder changes one thing with large consequences: the encoder outputs a probability distribution, typically a Gaussian described by a mean and a spread, instead of a single point, and training samples a code from that distribution.
Training balances two goals, combined in a quantity called the evidence lower bound. The reconstruction term rewards decoding an output that matches the input. A KL divergence term penalises each encoded distribution for straying from a simple prior, usually a standard normal distribution. That pull towards a common shape makes the latent space continuous, so nearby points decode to similar outputs and you can sample fresh points to generate new data. A device called the reparameterisation trick writes each sample as the mean plus the spread times random noise, which lets ordinary gradient descent train the encoder.
Diederik Kingma and Max Welling introduced the method in Auto-Encoding Variational Bayes, posted in December 2013; Rezende and colleagues published the closely related stochastic backpropagation technique in 2014. In a 2019 introduction, Kingma and Welling described VAEs as a principled framework for learning deep latent-variable models. Variants include the beta-VAE, which weights the KL term to encourage separate, interpretable factors, and the conditional VAE.
Many people now use a VAE without knowing it. A December 2021 paper by Robin Rombach and colleagues showed that diffusion image models could be trained far more cheaply in the compressed latent space of a pretrained autoencoder instead of on raw pixels. The widely used Hugging Face Diffusers library describes its AutoencoderKL component as a VAE with KL loss that encodes images into latents and decodes latents back into images. In such systems, the last step that turns a small grid of latent numbers into a full picture is often a VAE decoder.
In practice, then, a VAE is often a component rather than the product: it supplies the compact, smooth representation that another model works on, and the quality of its decoder shapes the final output.
It is a neural network that learns to compress data into a short code and rebuild it, while keeping the space of codes smooth and well organised. Because of that smoothness, you can pick a new point in the code space and decode it into a new, realistic example. It is one of the main families of generative models. A standard autoencoder maps each input to a single point and learns only to reconstruct it. A variational autoencoder maps each input to a probability distribution and adds a penalty that keeps those distributions close to a simple shared one. That makes the latent space continuous, so the model can generate new data as well as compress it. In latent diffusion image generators, a VAE encoder compresses images into a much smaller latent representation where the diffusion model does its work, which saves a great deal of computation. After the diffusion process, the VAE decoder turns the latent result back into a full-resolution image. A VAE learns by reconstructing its inputs through an encoder and decoder, balancing accuracy against a smooth latent space. A generative adversarial network trains a generator against a discriminator that tries to tell real data from fakes. VAEs also give you an encoder that maps data into the latent space, which GANs lack.Common questions
What is a variational autoencoder in simple terms?
What is the difference between an autoencoder and a variational autoencoder?
What does the VAE do in an image generator?
What is the difference between a VAE and a GAN?
Search for "variational autoencoder", "evidence lower bound", "reparameterization trick" or "latent diffusion VAE" to go deeper. The original Kingma and Welling paper and their 2019 introduction, both on arXiv, are the primary sources, and university course notes explain the maths step by step. Library documentation such as Hugging Face Diffusers shows how VAEs are used inside current image generators.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.