liveBook · Manning

Latent distribution

As explained in Build AI Drug Discovery Pipelines

A latent distribution is a probability distribution over unobserved variables that encode underlying factors of observed data.

A latent distribution represents an input molecule with a probability distribution over hidden variables rather than a single fixed point. In a molecular variational autoencoder, an encoder reads a tokenized SMILES string and produces distribution parameters such as the mean μ and log-variance. Sampling from those parameters yields a latent vector z that summarizes the molecule for generation. section 10.4.3 section 10.4.5

The latent distribution connects molecular encoding, generation, and training:

  • A bidirectional GRU processes the complete SMILES sequence in both directions and summarizes its dependencies. section 10.4.3
  • Linear projections convert the encoder summary into parameters for the latent distribution, enabling reparameterized sampling of z. section 10.4.5
  • A unidirectional GRU decoder receives z and generates the output SMILES string one token at a time. section 10.4.3
  • Training combines reconstruction loss with KL-divergence regularization; cyclical annealing helps prevent the decoder from ignoring z through posterior collapse. section 10.4.5

Molecular generation pipeline

A VAE-CYC implementation tokenizes a molecule with SmilesPE, encodes it with a bidirectional GRU, projects the summary to a latent distribution, samples z, and decodes z with a unidirectional GRU. New molecules are generated by sampling latent vectors from the prior and decoding them, then evaluating validity, uniqueness, novelty, and diversity. section 10.4.5

Figure 10.8 Bidirectional RNN Encoder Architecture for VAE-CYC. The encoder processes input molecules by first converting them from chemical structure to SMILES representation, then through an embedding layer that converts text to numerical vectors. A multi-layer bidirectional RNN encoder processes the sequence in both forward and backward directions. The final hidden states from both directions are concatenated and passed through a linear projection layer to generate latent distribution parameters. These parameters, combined with random noise through the reparameterization trick, produce the final latent vector representation of the input molecule.

Trace how chemical structures become SMILES tokens, bidirectional hidden states, latent distribution parameters, and sampled molecular representations. section 10.4.5

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Traces encoding, parameter projection, reparameterized sampling, decoding, and regularization, while evaluation metrics receive only a brief treatment.
Examples
Demonstrates latent distributions through VAE-CYC, SMILES tokenization, GRU encoder-decoder code, and temperature-based molecular sampling.
What you can do after
Builds a molecular variational autoencoder that samples latent vectors and decodes them into generated SMILES strings.
How it connects
Connects variational autoencoders with SMILES, bidirectional GRUs, reparameterization, KL divergence, latent space, and autoregressive decoding.

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.