Posterior Collapse and the KL Term
The failure where a VAE's latent code carries no information, why a powerful decoder makes it the optimal solution rather than an accident, and the fixes that each buy something different.
A text VAE trains cleanly. The loss goes down, the samples are grammatical, and then someone checks the KL term and finds it at 0.02 nats. The latent variable is carrying essentially no information about the input, the encoder has learned to ignore its input entirely, and the decoder is a very good unconditional language model wearing a VAE costume. Nothing crashed. The model found the optimum of the objective it was given.
Why collapse is optimal, not accidental
The ELBO decomposes into a reconstruction term and a KL term:
The KL term is a cost paid for every nat of information the encoder puts into \(z\). It is exactly zero when \(q(z \mid x) = p(z)\) for all \(x\), meaning the posterior ignores the data. So the model will only pay that cost if the decoder can convert the information into a larger improvement in reconstruction.
With a weak decoder, such as a factorised Gaussian over pixels, that trade is clearly worth it: the decoder cannot model correlations between output dimensions on its own, so it needs the latent. With a strong autoregressive decoder, it is often not worth it. A transformer decoder over text can model \(p(x)\) well without any latent, so the reconstruction gain from a informative \(z\) is small, the KL cost is not, and collapse is the better point on the objective. This is the central insight: posterior collapse is a property of the objective and the decoder capacity, not a training instability.
What the fixes actually do
KL annealing multiplies the KL term by a coefficient warmed from 0 to 1 over early training. Starting at zero lets the decoder learn to use \(z\) before paying for it, so by the time the full cost arrives the reconstruction gain is real. It is effective and it is fragile: the schedule is a hyperparameter, and too fast a ramp collapses anyway.
Free bits allocates a per-dimension KL budget that is not penalised, taking \(\max(\lambda, D_{\mathrm{KL},i})\) per latent dimension \(i\). Below \(\lambda\) nats the dimension is free, so there is no incentive to drive it to zero, and above it the usual pressure applies. This targets the failure directly rather than delaying it.
Weakening the decoder removes the reason to collapse. Restricting the decoder's receptive field, dropping out its input tokens, or removing skip connections all force it to rely on \(z\). The cost is a worse decoder, which is a real price and the reason this is unpopular in generative-quality-driven work.
Beta-VAE runs the dial the other way. Setting the KL coefficient above one deliberately increases the pressure, buying more disentangled and more prior-like latents at the cost of reconstruction. It is the same knob as annealing, turned in the opposite direction for a different goal, and it makes clear that "the right KL weight" depends entirely on whether you want a good generative model or a good representation.
Diagnosing it
Total loss will not show you collapse. Log the reconstruction and KL terms separately, and log per-dimension KL. A healthy model shows a KL of a few nats per active dimension with a clear split between active and inactive dimensions; a collapsed model shows near-zero everywhere. Mutual information between \(x\) and \(z\), estimable from a minibatch, is the direct measurement and the one worth putting on a dashboard.
When it breaks
Partial collapse is the common case and the easiest to miss. With 128 latent dimensions, a model may keep 6 active and collapse the rest. Aggregate KL looks acceptable, generation looks acceptable, and the effective latent capacity is a twentieth of what was provisioned. This is often fine, and it is always worth knowing.
Free bits changes what the objective is. With a free-bits floor, the loss is no longer a bound on the log-likelihood, so likelihood numbers reported under it are not comparable with numbers from a standard ELBO. Papers that report both without noting this are comparing different quantities.
Collapse can arrive through the variance channel. An encoder that drives \(\sigma \to 1\) and \(\mu \to 0\) has collapsed; so has one whose \(\mu\) varies but whose downstream decoder ignores it. The second is not visible in KL at all, and requires an intervention test: shuffle \(z\) across the batch and see whether reconstruction quality changes.
Fixing collapse does not guarantee useful latents. A model forced to use its latent can encode low-level detail that happens to reduce reconstruction error rather than the semantic factors you wanted. High KL is a necessary condition for an informative code, not a sufficient one.
14 flashcards for this concept
Click a card to reveal the answer.