---
title: Semi-Supervised JT-VAE SeMole
url: https://www.emergentmind.com/topics/semi-supervised-jt-vae-semole
type: topic
---

# Semi-Supervised JT-VAE SeMole

The Semi-Supervised Junction Tree Variational Autoencoder (SeMole) is a generative model that augments the Junction Tree VAE (JT-VAE) paradigm for molecular graphs with a semi-supervised learning framework. SeMole is specifically designed for molecular property prediction under scarcity of labeled data, exploiting both labeled and unlabeled molecules to improve sample efficiency and support property-conditioned molecular graph generation. The underlying approach integrates property prediction with conditional structure generation via multi-latent-variable variational inference and progressive pretraining [2208.05119].

## 1. Model Architecture

SeMole builds directly on the JT-VAE architecture, which factorizes each molecule \( G \) into two levels: (i) the junction tree \( T \) over chemically valid substructures ("scaffolds"), and (ii) the molecular graph \( G \) assembled from these substructures. The autoencoder is composed of four main subnetworks:

- **Tree encoder \( q_{\phi}(z_T \mid T) \)**: Implements a two-layer GRU over the node sequence of the junction tree, with learned substructure embeddings. It outputs a Gaussian posterior for the latent scaffold code \( z_T \in \mathbb{R}^d \).
- **Graph encoder \( q_{\phi}(z_G \mid G) \)**: Utilizes a Message-Passing Neural Network (MPNN) to aggregate node-level representations, yielding a Gaussian posterior for the latent code \( z_G \in \mathbb{R}^d \).
- **Tree decoder \( p_{\theta}(T \mid z_T, y) \)**: Predicts the topology and labeling of the junction tree, conditioned on both \( z_T \) and the molecular property variable \( y \).
- **Graph decoder \( p_{\theta}(G \mid T, z_G, y) \)**: Predicts the assembly of molecular substructures defined by the tree and the detailed attachment patterns and bond types, taking as input \( T \), \( z_G \), and \( y \). This subnetwork is implemented via another MPNN.

SeMole treats \( z_T \) and \( z_G \) as independent Gaussian priors: \( z_T \sim \mathcal{N}(0, I) \), \( z_G \sim \mathcal{N}(0, I) \), with a third latent variable \( y \sim \mathcal{N}(0, I) \) for the target molecular property, which is only partially observed.

The generative process is factorized as:
\[
p_{\theta}(y)\;p_{\theta}(z_T)\;p_{\theta}(z_G)\;
p_{\theta}(T \mid z_T, y)\;
p_{\theta}(G \mid T, z_G, y)
\]

Recognition models are formulated differently for labeled (\( (T, G, y) \)) and unlabeled (\( (T, G) \)) samples:
- For labeled: \( q_{\phi}(z_T, z_G \mid T, G, y) = q_{\phi}(z_T \mid T)q_{\phi}(z_G \mid G) \)
- For unlabeled: \( q_{\phi}(z_T, z_G, y \mid T, G) = q_{\phi}(y \mid T, G)q_{\phi}(z_T \mid T)q_{\phi}(z_G \mid G) \)

## 2. Semi-Supervised Learning Objective

The SeMole framework employs a semi-supervised variational inference scheme in the "M2" style of Kingma et al. (2014). Two evidence lower bound (ELBO) objectives are defined:

- **Labeled ELBO** (for \( (T, G, y) \)), denoted \( -\mathcal{L}(T, G, y) \):
\[
\begin{align*}
\log p_{\theta}(T, G, y) \geq \mathbb{E}_{q_{\phi}(z_T, z_G \mid T, G, y)}\Bigg[&
\log p_{\theta}(T \mid z_T, y)
+ \log p_{\theta}(G \mid T, z_G, y) \\
&+ \log p_{\theta}(z_T)
+ \log p_{\theta}(z_G)
+ \log p_{\theta}(y) \\
&- \log q_{\phi}(z_T \mid T)
- \log q_{\phi}(z_G \mid G)
\Bigg]
\end{align*}
\]

- **Unlabeled ELBO** (for \( (T, G) \)), denoted \( -\mathcal{U}(T, G) \):
\[
\begin{align*}
\log p_{\theta}(T, G) \geq \mathbb{E}_{q_{\phi}(z_T, z_G, y \mid T, G)}\Bigg[&
\log p_{\theta}(T \mid z_T, y)
+ \log p_{\theta}(G \mid T, z_G, y) \\
&+ \log p_{\theta}(z_T)
+ \log p_{\theta}(z_G)
+ \log p_{\theta}(y) \\
&- \log q_{\phi}(z_T \mid T)
- \log q_{\phi}(z_G \mid G)
- \log q_{\phi}(y \mid T, G)
\Bigg]
\end{align*}
\]
An additional entropy term \( \mathcal{H}[q_{\phi}(y \mid T, G)] \) appears due to the marginalization over \( y \).

The final objective combines labeled and unlabeled ELBOs, augmented with a weighted property prediction term:
\[
\mathcal{J} =
\sum_{(T,G,y) \in \mathcal{D}_L} \mathcal{L}(T,G,y)
+ \sum_{(T,G) \in \mathcal{D}_U} \mathcal{U}(T,G)
- \alpha \mathbb{E}_{(T,G,y) \in \mathcal{D}_L}[\log q_{\phi}(y \mid T, G)]
\]
where \( \alpha > 0 \) regulates the strength of the supervised property-prediction loss.

The reconstruction losses decompose into:
- Tree topology and label cross-entropy (for \( p_{\theta}(T \mid z_T, y) \))
- Graph attachment cross-entropy (for \( p_{\theta}(G \mid T, z_G, y) \))
- Two KL divergences: \( \mathrm{KL}[q(z_T \mid T) || p(z_T)] \) and \( \mathrm{KL}[q(z_G \mid G) || p(z_G)] \)

Classification/regression is enforced by the negative log-likelihood term \( -\log q_{\phi}(y \mid T, G) \), which is mean squared error for regression or cross-entropy for classification.

## 3. Pretraining and Training Stabilization

Training multi-latent-variable VAEs is empirically unstable. SeMole introduces a pre-training schedule ("SeMoleₚₑₜᵣₐᵢₙₑd", *Editor's term*), where the supervised loss term (\( \alpha \)) is set to zero for an initial warm-up period (epochs 1–10), meaning only the reconstruction ELBOs are active and the property prediction auxiliary network is not updated. During ramp-up (epochs 11–N), \( \alpha \) is increased linearly up to a maximum hyperparameter \( \alpha_{\max} \).

This staged optimization allows the model to first learn a robust reconstruction manifold before encouraging the disentanglement of molecular properties in latent space. This curriculum, based on Kingma et al. (2014) and Maaløe et al. (2016), improves both final accuracy and training stability.

## 4. Property-Conditioned Generation

Unlike vanilla JT-VAE, SeMole injects the molecular property code \( y \) into both the tree and graph decoders:

- The tree decoder conditions every structure and label prediction on \([z_T; y]\).
- The graph decoder's MPNN uses \([z_G; y]\), in combination with the tree embedding, to inform chemical graph assembly.

The inference network \( q_{\phi}(y \mid T, G) \) is a compact MLP over concatenated encoder embeddings, producing a Gaussian mean for property regression.

Through this property injection in both generative steps, the latent representations for structure (\( z_T \), \( z_G \)) are tightly coupled with the molecular property variable \( y \), enabling both property-conditional graph generation and property inference from molecular structure.

## 5. Experimental Protocol and Baselines

The experimental evaluation uses 310,000 molecules from ZINC 15, with three scalar properties computed via RDKit: Molecular weight (MolWt), LogP (Wildman–Crippen partition coefficient), and QED (Quantitative Estimation of Drug-likeness). Each property is standardized. Experiments simulate label scarcity by varying the labeled fraction between 5% and 50%.

A summary of dataset and protocol:

| Component            | Details                                      | Notes                                                    |
|----------------------|----------------------------------------------|----------------------------------------------------------|
| Dataset              | 310k from ZINC 15                            | Drug-like molecules                                      |
| Properties           | MolWt, LogP, QED                             | Standardized                                              |
| Test set             | 10,000 held-out molecules                    | Fixed                                                    |
| Labeled splits       | 5%, 10%, 20%, 50% labeled                    | Rest are unlabeled                                       |
| Validation set       | 5% of labeled data                           |                                                          |
| Hyperparameters      | Batch: 16, Adam lr: 1e-3, $\dim z_T{=}56$    | 2-layer GRU (tree), 3-layer MPNN (graph decoder)         |
| $\alpha_{\max}$      | Tuned in $[0.1,1.0]$                         | Used for property-signal ramp-up                         |

Baseline and ablation comparisons:
1. SSVAE (Kang & Cho 2018) operating on SMILES strings.
2. SeMoleₛᵤₚₑᵣᵥᵢₛₑd: graph JT-VAE without unlabeled data (\( \mathcal{D}_U = \varnothing \)).
3. SeMole: full semi-supervised, constant \( \alpha \).
4. SeMoleₚₑₜᵣₐᵢₙₑd: pretraining with warm-up and ramp-up of \( \alpha \).

## 6. Empirical Performance and Analysis

SeMole is evaluated using Mean Absolute Error (MAE) on the test set for property prediction. Results synthesized from Table 1 of [2208.05119]:

- With 5% labeled data:
    - LogP: SSVAE 0.133±0.002, SeMole 0.120±0.006, SeMoleₚₑₜᵣₐᵢₙₑd 0.117±0.001
    - QED:  SSVAE 0.038±0.000, SeMole 0.028±0.001, SeMoleₚₑₜᵣₐᵢₙₑd 0.021±0.000
- As the labeled fraction increases, SeMoleₚₑₜᵣₐᵢₙₑd maintains lower MAE than both SSVAE and the supervised-only SeMole variant. At 50% labels, MAE for LogP is ≈ 0.043 and for QED ≈ 0.009, compared to SSVAE’s 0.047/0.011.

Ablation findings indicate that removing unlabeled data (SeMoleₛᵤₚₑᵣᵥᵢₛₑd) significantly degrades performance under sparse supervision, while semi-supervised training with pretraining (SeMoleₚₑₜᵣₐᵢₙₑd) achieves both optimal accuracy and robust convergence. *This suggests that the model’s capacity to learn effective representations for property-conditioned generation relies on first establishing a solid generative manifold.*

Conditional molecule generation experiments show SeMoleₚₑₜᵣₐᵢₙₑd achieves 100% chemical validity, approximately 90% uniqueness/novelty, and approximately 80% of generated samples within ±5% of the target property value. SSVAE only attains ≈70% validity and ≈60% property accuracy.

## 7. Related Approaches and Significance

By marrying graph-structured molecular generation (JT-VAE backbone) with the probabilistic semi-supervised inference of Kingma et al. (2014), SeMole enables accurate molecular property prediction and controlled molecule synthesis in data regimes where labeled annotations are scarce. The model demonstrates empirically that reconstructive pretraining followed by progressive supervision yields more stable and performant semi-supervised VAEs for structured domains. The property-conditional decoding strategy notably enhances sample efficiency and controllability compared to previous graph and SMILES-based SSVAEs [2208.05119].

Source: https://www.emergentmind.com/topics/semi-supervised-jt-vae-semole