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
| Term | Formula | Meaning | Risk |
|---|---|---|---|
| Reconstruction | decoder explains observed data | may reward token-level fidelity but not utility | |
| Prior matching | encoder posterior stays close to prior | too strong can erase information | |
| Sampling | generate from prior | prior samples can be less valid than reconstructions | |
| Inference | encode observed data | representation 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
| Diagnostic | What It Checks |
|---|---|
| KL per dimension | whether only a few latent coordinates carry information |
| Mutual-information proxy | whether depends on |
| Prior-sample validity | whether random decodes to valid objects |
| Reconstruction validity | whether encoded examples decode correctly |
| Interpolation path | whether latent interpolation stays inside valid regions |
| Downstream probe | whether 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
| Object | Decoder Output | Extra Check |
|---|---|---|
| molecule string | SMILES or token sequence | chemical validity, uniqueness, scaffold novelty |
| molecular graph | atom and bond graph | valence, charge, stereochemistry, disconnected fragments |
| conformer | coordinates | chirality, bond geometry, conformer energy |
| protein sequence | amino acid sequence | length, motif, family leakage, function evidence |
| structure or complex | coordinates, distances, contacts | equivariance, 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?