wikillm

Concept · 18 papers · updated 2026-11-01

Variational autoencoder

A variational autoencoder (VAE) encodes an input as a distribution over a latent and is trained with reconstruction plus a KL term to a prior. Variants add a condition, discrete codes (dVAE, VQ-VAE), adversarial or disentangling penalties, or a diffusion prior on the latent. Cards cover world models, zero-shot features, grasps, motion, video, depth, audio goals and design metrics.

generative-modelslatent-spaceautoencodervariational-inferencedisentanglementvector-quantization

Markdown12 min read

AI-compiled overview, updated 2026-11-01, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

Overview

A VAE has an encoder that maps an input to the mean and spread of a Gaussian over a latent code, a decoder that maps a latent back to the input space, and a loss that is the reconstruction error plus a KL divergence between the encoder's Gaussian and a prior, usually a standard normal. The loss is a bound on the data likelihood 2103.04922 §3. The latent is drawn with the reparameterisation trick, z = mu + sigma * eps, so gradients reach the encoder 2103.04922 §3 2103.14274 §3.1. At generation time the encoder is usually dropped, and a latent is drawn from the prior and decoded.

The cards on this page share that core and change one or more parts:

  • the condition: a label, a class embedding, a previous pose or a point cloud is given to both encoder and decoder;
  • the latent type: continuous Gaussian, or discrete codes from a codebook;
  • the regulariser: the KL term is weighted differently, or replaced by an adversarial or moment-matching term;
  • what sits on top: a policy, a planner, a transformer prior, or a diffusion model running in the latent space.

Blurry samples are a known property of the plain Gaussian form. The survey links them both to the likelihood objective and to the restrictiveness of the Gaussian posterior, and reports evidence for the second cause 2103.04922 §3.

Variants

Plain Gaussian VAE as a compressor

The VAE shrinks observations so that a small learner can work on them. World Models trains a convolutional VAE on 64x64 frames, with a 32-dimensional latent for car racing and 64 for VizDoom 1803.10122 §3.2 1809.01999 app. A.2. A single linear controller on the latent and the recurrent state reaches 906 ± 21 on CarRacing-v0 1803.10122 tab. 2. The VizDoom controller is trained inside the learned model and then run on the real game, with 1092 ± 556 at temperature 1.15 1809.01999 tab. 2. The two cards report the same numbers for these runs. The first is World Models and the second is Recurrent World Models.

For a locomotion policy, a CNN-VAE maps a 20x40 terrain height map to a 16-value latent 2512.12993 §II.B. The authors report that the latent size of 16 learns faster than 64 or the full map, and that policies stay above 80% success on the tested terrains in simulation 2512.12993 §IV.A 2512.12993 §IV.E. The card is Learning Terrain Aware Bipedal Locomotion.

Two VAEs with 64-dimensional latents can also map one image domain onto another through a mixture density network, but the domain-transfer result is only shown as examples 1812.01718 §3.2. See Deep Learning for Classical Japanese Literature.

Conditional VAE

The condition is concatenated to the encoder input and to the latent before decoding.

VAE with a diffusion prior in latent space

A VAE compresses the data, and a diffusion model learns the distribution of the latent. The diffusion model can then be sampled with fewer steps.

  • Motion. A transformer VAE encodes a motion clip into one 256-d latent token, and a transformer denoiser runs diffusion on that token with classifier-free guidance 2212.04048 §3.1 2212.04048 §5. It reports FID 0.473 on HumanML3D against 0.544 for MDM 2212.04048 tab. 1. For 2048 clips with 50 DDIM steps, it takes 10.24 s against 225.28 s for MDM 2212.04048 tab. 10. See Motion Diffusion in Latent Space.
  • Grasps. In the same design, the grasp latent is sampled from the VAE prior and refined by a DDPM before decoding 2312.11243 §3.2. On 100 grasps for one scene, VAE-only sampling takes 0.02 s with median success 0.660, DDIM with 100 steps takes 0.75 s with 0.756, and DDPM with 1000 steps takes 7.39 s with 0.792 2312.11243 tab. 1.

Discrete VAE and VQ-VAE

The latent is a grid of indices into a learned codebook. The encoder output is mapped to the nearest code, or to a sample from a categorical distribution.

  • dVAE with Gumbel-softmax. A 256x256 image becomes a 32x32 grid of tokens from 8192 codes. The gradient passes through a relaxed categorical sample, and the relaxation temperature is annealed 2102.12092 §2.1. A transformer then models caption tokens and image tokens as one sequence 2102.12092 §2.2. See Zero-Shot Text-to-Image Generation.
  • VQ-VAE with an EMA codebook. VideoGPT uses 3D convolutions and axial attention, a codebook updated by exponential moving average with decay 0.99, and a straight-through gradient 2104.10157 §2.1. Its latent of 8x32x32 has the lowest FVD in the sweep, 103.6 2104.10157 tab. 5. The headline FVD of 103.3 on BAIR is in 2104.10157 tab. 1. See VideoGPT.

Adversarially regularised autoencoder

CAAE drops the KL term. A discriminator on the codes pushes them toward a uniform prior, and a second discriminator judges (image, age) pairs 1702.08423 §4.3 1702.08423 §4.4. It needs no paired images of one person at different ages, and a user study prefers its faces over prior work at 52.77% of votes 1702.08423 §1 1702.08423 §5.3. The card is listed under this concept, but its objective has no KL term. See Age Progression/Regression by Conditional Adversarial Autoencoder.

Disentangling VAEs

beta-VAE, FactorVAE, beta-TCVAE and DIP-VAE add penalties on the aggregate posterior to separate factors of variation 1905.12506 §2. Across 360 encoders trained on two toy datasets, FactorVAE and beta-VAE scores track the accuracy of a downstream reasoning model in the few-sample regime. After 100K steps, reconstruction error tracks accuracy better 1905.12506 §4.2.2. See Are Disentangled Representations Helpful for Abstract Visual Reasoning?.

VAE as a pretrained component at test time

A pretrained autoencoder need not be trained in the same pipeline. A depth method averages the latents of several exposures of one scene inside the Stable Diffusion VAE, decodes the average, and feeds it to a depth model 2408.06083 §3.3. The fusion step adds almost nothing on the transparent-and-mirror region: 0.859 to 0.860 2408.06083 tab. 3. The main gain comes from the training changes. See Towards Robust Monocular Depth Estimation.

Latent-variable guidance inside iterative reasoning

A recursive reasoner adds a learned Gaussian guidance term to each latent step. It is trained with an ELBO over the trajectory, using a posterior that sees the target and a prior that does not, and it uses truncated gradients 2605.19376 §2.2. At test time, N trajectories are drawn from the prior and the most frequent answer is returned 2605.19376 §2.3. Removing the guidance drops Sudoku accuracy to the deterministic baseline, and guidance without noise fails completely 2605.19376 tab. 3. The card reports 96.1% on Sudoku-Extreme at N = 20 2605.19376 tab. 8. See Generative Recursive Reasoning.

EEG-to-media survey

The EEG survey describes VAE decoders as one of several generators in EEG-to-image work, with no numeric comparison 2502.12048 §4.3. Its best text number, a BLEU-1 of 52.38 on ZuCo, comes from a different family 2502.12048 tab. 4. See A Survey on Bridging EEG Signals and Generative AI.

When to use which

The choice depends on what the downstream step needs and what the budget allows.

SituationUseWhyEvidence
A compact image latent for a small controller, no labelsPlain Gaussian VAEKeeps the policy small and sample-efficient in the cards' setting1803.10122 §2 2512.12993 §IV.A
Need features for classes with no examples, from attributesConditional VAE, then a classifierGenerates pseudo-features for unseen classes1709.00663 alg. 1 1709.00663 tab. 2
Tight latency, sample success matters lessVAE only, no latent diffusion0.02 s against 7.39 s per 100 grasps, with lower median success2312.11243 tab. 1
Sample success matters more and the diffusion cost is acceptableVAE with a latent diffusion priorHigher median success in the grasp study, DDIM at 0.75 s2312.11243 tab. 1 2212.04048 tab. 10
The next stage is a transformer over tokensdVAE or VQ-VAEDiscrete codes can be modelled one token at a time2102.12092 §2.2 2104.10157 §3
Paired data is scarce, conditions are attributesConditional VAE with adversarial code regularisationNo paired images needed1702.08423 §1
Interest in disentangled factorsbeta-VAE familyGains are clearest early in training and fade later1905.12506 §4.2.2
Sharp samples are the priorityCompare against GANs or diffusionThe survey notes plain VAEs give blurrier samples2103.04922 §3 2103.04922 §9
Comparing a VAE with a GAN on a design taskSeveral metrics, not one similarity scoreSimilarity alone can rank models wrongly2302.02913 §1 2302.02913 §4.5

Implementation sketch

The core below is the common part. Each card adds its own condition, codebook or prior. Cards disagree on the details noted under the sketch.

Pseudocode
# Core VAE objective shared by the cards  [arxiv:2103.04922 §3] [eq. 13]
# Input: x (B, D), optional condition c (B, C); latent size J
# Output: scalar loss to minimise

def vae_loss(encoder, decoder, x, c, beta):
    # Encoder gives mean and log-variance per latent unit  [arxiv:2103.04922 §3]
    mu, logvar = encoder(x, c)                        # (B, J) each
    # Reparameterised sample; gradients reach the encoder  [arxiv:2103.14274 §3.1]
    eps = normal_like(mu)
    z = mu + exp(0.5 * logvar) * eps                  # (B, J)
    # Decoder reads the sample and the condition  [arxiv:1709.00663 §3.2]
    x_hat = decoder(z, c)
    # Reconstruction term; the cards use squared error, L1 or a likelihood
    recon = sum((x - x_hat) ** 2)
    # Closed-form KL to N(0, I)  [arxiv:2103.04922 eq. 13]
    kl = -0.5 * sum(1 + logvar - mu**2 - exp(logvar), axis=1)
    # beta is a free weight; cards use values from 1e-4 to 1.0  [see below]
    return mean(recon + beta * kl)
Pseudocode
# Generation: draw from the prior and decode  [arxiv:1803.10122 §3.2]
# [arxiv:1709.00663 alg. 1]
def generate(decoder, condition, n):
    # Standard normal draws, one per sample  [arxiv:1709.00663 alg. 1]
    z = normal(size=(n, J))
    # Decode with the condition appended, if there is one  [arxiv:1709.00663 §3.2]
    return decoder(z, condition)

Where the cards differ:

  • KL weight. The cards use very different values. MLD's released code uses 1e-4 2212.04048 §3.1. GraspLDM anneals from 1e-7 to 0.1 over the first half of training 2312.11243 §3.3. The Motion VAE paper uses 0.2, and the released code uses 1.0 2103.14274 §3.4. GRAM uses between 0.015 and 0.5 depending on the task 2605.19376 app. B.2. Tune it and state the value used.
  • Sum or mean. GraspLDM's code averages the reconstruction over pose dimensions and sums the KL over latent dimensions. That changes the effective KL weight, and the card warns that summing the reconstruction would weight the KL six times less 2312.11243 §3.3. The audio-prior code sums the KL over the batch and averages the MSE, so its weighting depends on batch size 2412.00949 §3.4.
  • Std or variance. The terrain paper calls sigma a variance but uses it as a multiplier, so whether the encoder outputs a std or a log-variance is not settled 2512.12993 §II.B. Choose one and check the KL.
  • Inference sample. Some cards sample at test time, some do not state it, and the audio prior draws fresh noise on every call 2412.00949 Pitfalls. Test the mean and the sample, and report which one you used.
  • Discrete gradients. The dVAE relaxes the categorical sample and anneals the temperature with a cosine schedule. The card says linear annealing diverged 2102.12092 app. A.2. VQ-VAE uses a straight-through estimator instead 2103.04922 §3.2.
  • Bound validity. The dVAE paper says its bound is exact only at beta = 1, and it trains with beta = 6.6 2102.12092 §2 2102.12092 app. A.2. The objective is then no longer a strict bound.

Contradictions

  • Which family gives better samples. The survey's conclusion says GANs have led on sample quality, and its table puts a convolutional VAE at FID 106.37 on CIFAR-10 against 14.73 for BigGAN 2103.04922 §9 2103.04922 tab. 1. The design-metrics paper runs a 2-D six-mode test with one VAE and one GAN. The VAE scores higher on precision-recall F1 (0.475 against 0.386) and AUC, while the GAN scores better on nearest-datapoint distance and MMD 2302.02913 tab. 2. The paper runs one instance per model and cautions that the result may not carry over 2302.02913 §4.5. The two sources use different data and metrics, so neither settles the question.
  • Size of the KL weight. Papers that use the same family choose weights that differ by orders of magnitude (see the sketch). No card gives a rule that carries over.
  • Best latent size. VideoGPT's best BAIR latent is the 8x32x32 grid, and its largest latent gives worse samples, which it attributes to limited compute for the prior 2104.10157 tab. 5 2104.10157 §4.7. The terrain card picks 16 for policy learning while its loss curves favour 32 to 64 2512.12993 Pitfalls. These are optima for different downstream targets, not conflicting measurements of one quantity.
  • Bound exactness. The survey writes the training objective as the bound without caveat 2103.04922 §3. The dVAE paper states that the bound is exact only at beta = 1 2102.12092 §2.

Papers

Source and license

Compiled from the papers listed on this page, all published under CC BY, CC BY-SA or CC0, with citations. See each paper's page for its authors and license.