Variational Autoencoder (VAE)

A VAE learns a latent-variable generative model by jointly training an encoder and decoder to maximize a variational lower bound on the data likelihood.

The evidence lower bound is:

The first term rewards reconstruction; the KL term regularizes the latent distribution.

The generative process and inference model are:

The reparameterization trick makes gradients flow through stochastic latent samples:

For a -VAE style objective:

where controls the reconstruction-latent regularization tradeoff.

Why It Matters

  • Provides a structured, continuous latent space for sampling and interpolation.
  • A building block in many molecular and protein generators.
  • Trades off reconstruction quality against latent regularization.

Objective Contract

TermFormulaMeaningRisk
Reconstructiondecoder explains observed datamay reward token-level fidelity but not utility
Prior matchingencoder posterior stays close to priortoo strong can erase information
Samplinggenerate from priorprior samples can be less valid than reconstructions
Inferenceencode observed datarepresentation may not be useful for downstream tasks

When reading a VAE paper, separate reconstruction evidence from generation evidence:

Good reconstructions do not prove that prior samples are valid, diverse, novel, or useful.

Latent Diagnostics

DiagnosticWhat It Checks
KL per dimensionwhether only a few latent coordinates carry information
Mutual-information proxywhether depends on
Prior-sample validitywhether random decodes to valid objects
Reconstruction validitywhether encoded examples decode correctly
Interpolation pathwhether latent interpolation stays inside valid regions
Downstream probewhether captures the property claimed by the paper

Posterior collapse can be described as:

which means the latent variable carries little input-specific information.

Computational Biology Use

ObjectDecoder OutputExtra Check
molecule stringSMILES or token sequencechemical validity, uniqueness, scaffold novelty
molecular graphatom and bond graphvalence, charge, stereochemistry, disconnected fragments
conformercoordinateschirality, bond geometry, conformer energy
protein sequenceamino acid sequencelength, motif, family leakage, function evidence
structure or complexcoordinates, distances, contactsequivariance, residue mapping, pose quality

For molecule and protein generation, a VAE result should not stop at ELBO. It should also report validity, diversity, novelty, and the downstream task boundary.

Failure Modes

  • Posterior collapse: the decoder ignores and the latent carries little information.
  • Over-regularization: samples are smooth but reconstructions are poor.
  • Invalid decoding: latent samples map outside the valid output space.
  • Latent interpolation can look meaningful without matching downstream utility.

Checks

  • Is the latent space collapsing or being ignored by the decoder?
  • Does the reconstruction–KL balance match the goal?
  • Are latent samples decoding to valid, diverse outputs?
  • Is validity evaluated on prior samples, not only reconstructions?
  • Is the decoder likelihood appropriate for the data type?
  • Are reconstruction, representation, and generation claims evaluated separately?
  • If used for molecules or proteins, are invalid samples counted in the denominator?