liveBook · Manning

Kullback–Leibler divergence

As explained in Build AI Drug Discovery Pipelines

Kullback-Leibler divergence is a measure of how one probability distribution differs from a reference probability distribution.

Kullback–Leibler divergence (KL divergence) measures how far a predicted probability distribution differs from a reference distribution. In a variational autoencoder (VAE), it compares each molecule’s latent distribution q(z|x) with a standard-normal prior p(z). section 10.3

A VAE encoder maps each molecular SMILES string to a probability cloud, commonly described by a mean μ and variance σ², rather than a single latent point. The KL term pulls these clouds toward a shared prior, helping turn disconnected latent islands into a continuous space that can be explored by sampling. section 10.3 section 10.5

Training combines reconstruction loss with KL regularization: L = reconstruction_loss + β KL. Reconstruction preserves the input SMILES, while β controls how strongly the latent distribution follows the prior. Excessive or poorly scheduled regularization can contribute to posterior collapse, where the decoder ignores the latent representation. section 10.3 section 10.4.5

Within molecular VAE training, KL divergence supports several practical operations:

  • Regularize the latent distribution toward a standard normal prior. section 10.3
  • Balance reconstruction accuracy against a smooth, sampleable latent space through the KL weight β. section 10.3
  • Use cyclical annealing to vary the KL weight during training and reduce posterior collapse. section 10.4.5

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines the objective and intuition, then stops short of the probabilistic derivation and complete training implementation.
Examples
Uses molecular SMILES, Gaussian latent clouds, a standard-normal prior, and the VAE-CYC training pipeline as concrete examples.
What it assumes
Assumes basic probability distributions, autoencoder reconstruction, latent vectors, and molecular SMILES sequence modeling.
What you can do after
Build molecular VAEs that regularize latent distributions and generate molecules by sampling from the prior.
How it connects
Connects latent spaces, variational autoencoders, reconstruction loss, standard normal priors, posterior collapse, and cyclical annealing.

Also explained in

Compare how 19 books explain Kullback–Leibler divergence →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.