Self-Labeling of Fully Mediating Representations by Graph Alignment

Martijn Oldenhof, Adam Arany, Yves Moreau, Jaak SimmarXiv 2021 · DOI

TL;DR

This paper introduces an iterative self-labeling framework that uses graph alignment to perform data-efficient domain adaptation for optical chemical structure recognition. By leveraging a "fully mediating" planar embedding layer, the method generates rich, pixel-level training labels from standard molecular graph strings (like SMILES), boosting target domain accuracy by up to 4x and outperforming state-of-the-art rule-based systems.

What Problem Does This Paper Address?

Converting a 2D image of a chemical compound into a machine-readable graph structure (such as a SMILES string or MOLfile) is a crucial task for automating data extraction from scientific literature and patents. While humans can easily adapt to different image styles (varying line widths, fonts, or orientations), machine learning models notoriously struggle to generalize to new visual domains.

To train highly accurate models, researchers often rely on "rich labels"—pixel-wise annotations showing the exact coordinates of every atom and bond. However, these labels are expensive and time-consuming to produce manually. In contrast, standard labels (the final graph structure) are abundant but lack spatial layout information. This paper addresses the challenge of adapting a model to a new visual domain using only standard graph labels, eliminating the need for manual pixel-level re-annotation.

Methods

The authors adopt a fully mediating representation framework. Instead of mapping an image $U$ directly to a graph $W$, the model factors the problem into two steps: $U \rightarrow V \rightarrow W$, where $V$ is a planar embedding (a pixel-level segmentation map of the atoms and bonds).

Figure 1: We are interested to learn f : U →W having a fully mediating representation V such that f factors into U →V →W. In the case of optical graph recognition of chemical compounds from 2D images, the fully mediating layer is represented using the planar embedding of the chemical graph structure we are predicting.

To adapt a pre-trained model to a new target domain without rich labels for $V$, they propose an iterative Self-Labeling by Graph Alignment algorithm:

  1. Predict: The current model predicts the planar embedding $\hat{v}$ and projects it to a graph structure $\hat{w}$.
  2. Align & Correct: If $\hat{w}$ does not match the true target graph $w$, the algorithm uses Graph Edit Distance (GED) to find the minimal set of corrections (substitutions or insertions) needed to align the prediction with the ground truth.
  3. Label Generation: If a simple, valid correcting edit is found (e.g., maximum of 2 node substitutions or 1 edge substitution), it is applied to create a corrected pseudo-rich label $v$.
  4. Retrain: These newly generated rich labels are upsampled and added to the training set to refine the model for the next iteration.
Figure 2: Two examples of chemical compounds graphs with their graph edit distance. The nodes of the graphs are first aligned before computing the graph edit distance. The node alignments are marked with the gray dashed arrows. The differences after graph alignment are highlighted and the substitutions are marked with the red dashed arrows.

Datasets

  • Source Domain: ~130K synthetically generated, rich-labeled chemical compound images derived from the ChEMBL database using an RDKit fork.
  • Target Domains (Evaluation):
  • Indigo Dataset: 5,000 randomly sampled pairs (4,000 for adaptation, 1,000 for testing). This dataset features a significantly different visual style compared to the source domain.
  • Maybridge Dataset: 5,000 randomly sampled pairs (4,000 for adaptation, 1,000 for testing), possessing a visual style closer to the source domain.

Key Insights and Ideas

  • Learning the Unseen: Remarkably, the graph alignment mechanism allows the model to learn entirely new, unseen atom types and functional groups (such as R-groups or $NO_2$ superatoms) in the target domain. Because the true graph label dictates that an atom must be there, the alignment step forces the model to map the unfamiliar visual text/structure to the correct node type.
  • The Power of Mechanistic Priors: Forcing the network through a fully mediating layer ($V$) restricts the hypothesis space to physically plausible models. This structural constraint is what makes graph-based error correction possible in the first place.
  • Enhanced Interpretability: Because the model outputs an intermediate planar embedding, human experts can visually inspect where a prediction failed (e.g., distinguishing between a low-level segmentation error and a high-level classification error), making it far less of a "black box" than direct image-to-SMILES end-to-end models.

Key Results

  • Indigo Dataset: The baseline pre-trained model performed poorly due to style differences, achieving only ~10% accuracy. After applying the proposed correcting graph alignment method, performance jumped to 39% accuracy—a nearly 4x improvement using only 4,000 target data points.
  • Maybridge Dataset: The proposed domain adaptation approach reached 86.3% accuracy, outperforming existing rule-based and state-of-the-art tools like OSRA (80.4%), Molvec (78.4%), and the original MolRec paper baseline (83.8%).
  • Correcting vs. Exact Alignment: Experiments proved that allowing a small number of graph edits ("correcting graph alignment") significantly outperforms "exact graph alignment" (which discards any prediction that isn't completely perfect initially).

Limitations and Future Work

  • Dependence on the Initial Model: The self-labeling loop relies on the pre-trained model being accurate enough to generate predictions within a 1-to-2 edit distance of the ground truth. If the initial model's predictions are completely wrong, graph alignment fails, no pseudo-labels are generated, and the adaptation stalls.
  • Computational Cost: Calculating graph edit distances and iteratively retraining deep convolutional networks is computationally expensive. One iteration of the pipeline took approximately 46 hours across the hardware setup described in the paper.
  • Future Applications: The authors suggest this framework could be extended beyond chemistry to other structural scene representation tasks, such as converting 2D/3D images of roads or objects into relational scene graphs.

Summary updated

Abstract

To be able to predict a molecular graph structure ($W$) given a 2D image of a chemical compound ($U$) is a challenging problem in machine learning. We are interested to learn $f: U \rightarrow W$ where we have a fully mediating representation $V$ such that $f$ factors into $U \rightarrow V \rightarrow W$. However, observing V requires detailed and expensive labels. We propose graph aligning approach that generates rich or detailed labels given normal labels $W$. In this paper we investigate the scenario of domain adaptation from the source domain where we have access to the expensive labels $V$ to the target domain where only normal labels W are available. Focusing on the problem of predicting chemical compound graphs from 2D images the fully mediating layer is represented using the planar embedding of the chemical graph structure we are predicting. The use of a fully mediating layer implies some assumptions on the mechanism of the underlying process. However if the assumptions are correct it should allow the machine learning model to be more interpretable, generalize better and be more data efficient at training time. The empirical results show that, using only 4000 data points, we obtain up to 4x improvement of performance after domain adaptation to target domain compared to pretrained model only on the source domain. After domain adaptation, the model is even able to detect atom types that were never seen in the original source domain. Finally, on the Maybridge data set the proposed self-labeling approach reached higher performance than the current state of the art.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Indigo data setProposed graph-aligning rich-labeling method (after domain adaptation)accuracy39%+29 vs baselinedomain-adaptation · target-labeled-points=4000
Source quote
L232: Machine learning models often are faced with the problem to not generalize well to a new domain. This is also the case for chemical graph recognition from images. We have shown that fully mediating layers can be exploited in machine learning models to adapt in data efficient way to new domains, without the need of rich expensive labels as they can be generated using our method. In the case of chemical graph recognition we empirically show that our method is able to adapt to a new domain of chemical compounds, with previously unseen atom or bond types. Our rich-labeling method required only 4,000 normal labeled points in the target domain to go from 10% accuracy to 39%, i.e., almost 4x improvement in the difficult Indigo data set. Furthermore, on Maybridge data set, again using only 4,000 images, we reached high accuracy obtaining better performance than the current state of the art.
Reported baseline / comparator measurements (1)
BenchmarkMethodMetricScoreProtocol / Evidence
Indigo data setPretrained model only on the source domain (pre-adaptation) baselineaccuracy10%pre-adaptation
Source quote
L232: Machine learning models often are faced with the problem to not generalize well to a new domain. This is also the case for chemical graph recognition from images. We have shown that fully mediating layers can be exploited in machine learning models to adapt in data efficient way to new domains, without the need of rich expensive labels as they can be generated using our method. In the case of chemical graph recognition we empirically show that our method is able to adapt to a new domain of chemical compounds, with previously unseen atom or bond types. Our rich-labeling method required only 4,000 normal labeled points in the target domain to go from 10% accuracy to 39%, i.e., almost 4x improvement in the difficult Indigo data set. Furthermore, on Maybridge data set, again using only 4,000 images, we reached high accuracy obtaining better performance than the current state of the art.
BibTeX
@misc{oldenhof2021self,
  author = {Martijn Oldenhof and Adam Arany and Yves Moreau and Jaak Simm},
  title = {{Self-Labeling of Fully Mediating Representations by Graph Alignment}},
  year = {2021},
  eprint = {2103.14133},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.14133},
}
Figure