Posterior Collapse and KL Annealing
When a VAE's decoder gets powerful enough to reconstruct data without reading the latent code, the encoder gives up and the KL term collapses to zero — and the standard fix is to turn the KL penalty up slowly instead of all at once.
Prerequisites: Variational Autoencoders, KL Divergence
Train a variational autoencoder with a strong decoder — say an autoregressive text or audio decoder — and something strange can happen: the latent code stops mattering. The encoder's posterior collapses onto the prior for every single input, meaning carries zero information about . Reconstructions still look fine, because the decoder learned to reproduce plausible outputs on its own. But the latent space is useless: sample two different 's and you get the same output, because the decoder never learned to listen to in the first place.
The analogy: a student who stops reading the prompt
Imagine a student graded only on essay quality, never on whether the essay actually answered the prompt. If the student is skilled enough to write a plausible essay from any one-word prompt, they will stop reading prompts carefully — there's no penalty for ignoring them, and ignoring them is easier. That is posterior collapse: the decoder is the skilled student, the latent code is the prompt, and the training objective never explicitly rewards the decoder for using it.
Why the ELBO invites this
The VAE objective, the evidence lower bound, is a sum of two competing terms:
In words: reward accurate reconstruction, but penalize the encoder for straying from the prior. Early in training, before has learned anything useful, the cheapest way to raise the ELBO is often to make identical to the prior for every — the KL term drops to exactly zero, and if the decoder can still reconstruct reasonably well without , reconstruction loss barely suffers. That local optimum is easy to fall into and hard to climb back out of, because once the decoder ignores , the reconstruction gradient carries no signal telling the encoder to make informative again.
Worked example 1: the collapse is a real optimum, in numbers
Suppose, per sequence, reconstruction using an informative reaches log-likelihood nats, and the KL cost of that informative posterior is nats. A decoder good enough to ignore instead reaches nats (worse reconstruction, but no KL cost at all). Compare full ELBOs:
Collapse wins, , even though its reconstruction is 5 nats worse — the KL penalty outweighs the reconstruction gain. This is why plain ELBO training can prefer a useless latent space.
Worked example 2: annealing tips the balance
KL annealing multiplies the KL term by a weight that ramps from up to over training, using . With a linear schedule :
- Step 2,000 (): informative ; collapsed . Informative now wins.
- Step 5,000 (): informative ; collapsed . Informative still wins, by a narrower margin.
- Step 10,000 (): back to the original numbers, informative loses on paper — but by then the decoder has already learned to depend on , so abandoning it would hurt reconstruction, not just cost KL. The early low- window is what gets established before the full penalty arrives.
Posterior collapse happens because the ELBO lets the model pay zero KL cost by making uninformative, and a strong-enough decoder can still reconstruct well without it. KL annealing — starting the KL weight near 0 and raising it slowly — gives the encoder a window to make genuinely useful before the full penalty arrives.
What this means in practice
Posterior collapse matters whenever a VAE's decoder is autoregressive or otherwise expressive enough to model on its own — language VAEs and audio VAEs are the classic victims, but any financial sequence model with a powerful decoder (a VAE meant to generate synthetic price paths, say) can suffer the same failure, silently producing a latent space that carries no interpretable structure for stress-testing or interpolation. Besides KL annealing, practitioners use "free bits" (only penalizing KL above a small floor per latent dimension) and weakening the decoder (dropout on its own inputs) to force it to lean on .
A model with collapsed posteriors can still show a good reconstruction loss and a good-looking ELBO, so collapse is easy to miss by only watching the loss curve. The tell is the KL term itself sitting at or near zero throughout training — always plot it separately from the reconstruction term, not just their sum.
Related concepts
Practice in interviews
Further reading
- Bowman et al., Generating Sentences from a Continuous Space (2016)