AI Model Wiki

    Skip to main content
    Back to Glossary

    VAE (Variational Autoencoder)

    A Variational Autoencoder (VAE) is a generative model that learns a probabilistic mapping between raw data — images, audio, text — and a compact, structured latent space. Unlike a plain autoencoder that maps each input to a fixed point, a VAE maps each input to a distribution (typically a Gaussian), then samples from that distribution during reconstruction. Training optimises a combined loss: reconstruction fidelity plus a KL-divergence term that keeps the learned distributions close to a standard normal prior, ensuring the latent space is smooth and navigable.

    Think of it like a cartographer who, instead of pinning each city to one exact coordinate, draws a small probability cloud around each location. The overlapping clouds mean you can pick any point on the map and interpolate sensibly between nearby cities — a property that makes the map useful for generating new, plausible locations rather than just looking up known ones.

    VAEs are used both as standalone generators and as components in larger pipelines. Stable Diffusion, for example, uses a VAE to compress full-resolution images into a smaller latent grid before the diffusion process operates:

    # Encode an image to latent space, then decode back
    latent = vae.encode(pixel_tensor).latent_dist.sample() * 0.18215
    reconstructed = vae.decode(latent / 0.18215).sample
    

    This compression dramatically reduces the computation needed during the denoising steps without losing perceptual quality.

    VAEs are closely related to Latent Space, which they help define; Diffusion models that often use them as encoders; GANs, which offer a competing approach to generative modelling with sharper but less diverse outputs; and Embedding techniques more broadly.

    You will encounter VAEs when studying generative image models, in papers on representation learning, and whenever a system needs a smooth, continuous latent space that supports interpolation or controlled generation.

    AI Terminology
    Glossary