                                 Hierarchical Graph Tokenization for Molecule-Language Alignment



where h1 , ..., hn are node embeddings from a GNN typi-                    functional groups by LGLMs. Specifically, we consider

cally pretrained through self-supervised learning on large-                the 38 common functional groups in RDKit1 and leverage

scale molecular datasets such as ZINC250k (Sterling &                      RDKit (Landrum, 2016) to detect the existence. We adopt

Irwin, 2015), fn is the adapter to project the node tokens                 3, 300 molecules from ChEBI-20 (Edwards et al., 2021)

to the LLM tokens. There are various options to tokenize                   and query the existence of a functional group:

a molecule (Liu et al., 2023d). In this work, we consider

a state-of-the-art tokenizer (Xia et al., 2023) that pretrains                    Is there a <functional group name>

a VQVAE (van den Oord et al., 2017) with masked atoms                                     in the molecule?

modeling and constructs a codebook Z to discretize atoms:

zu = arg mini ||hu − ei ||2 , where zu ∈ Z is the quantized

                                                                           Then, we examine the outputs from LGLM meaning “Yes”

index of atom u, and ev is the codebook embedding of the

                                                                           or “No”. For each molecule, we construct questions with

i-th entry. The codebook is trained through a reconstruction

                                                                           positive answers for all kinds of functional groups detected

loss with respect to some attribute vi of atom i:

                                                                           in the molecule, and questions with negative answers for

          n                                  n                             randomly sampled 6 functional groups from the remaining.

       1X             viT v̂i             1X                               Hence MotifHallu consists of 23, 924 questions. While

Lr =         (1 −                    )γ +       ||sg[hi ] − ezi ||22

       n i=1      ||vi || · ||v̂i ||      n i=1                            it is easy to scale up MotifHallu with more molecules

               n                                                           and functional groups, we find that the current scale is al-

           βX

       +         ||sg[ezi ] − hi ||22 ,                                    ready sufficient to demonstrate the issue (Table 2).

           2 i=1

                                                           (5)

where sg[·] is the stop-gradient operator in straight-through              4. Hierarchical Graph Tokenization

estimator (Bengio et al., 2013), v̂i is the reconstructed at-              To improve the molecule-language alignment, we propose

tribute of atom i with a decoder, and β is a hyperparamter.                a new strategy called HIerarchical GrapH Tokenization

In Mole-BERT, the attribute is simply the type of atom.                    (HIGHT), which contains a hierarchical graph tokenizer

Mole-BERT also manually partitions the codebook into                       and a hierarchical molecular instruction tuning dataset to

groups of common atoms such as carbon, nitrogen, and                       augment the inputs with hierarchical information.

oxygen to avoid codebook conflicts (Xia et al., 2023).

Intuitively, the trained atom tokens encode some contextual                4.1. Hierarchical Graph Tokenizer

information, such as the neighbors of the atoms. However,

                                                                           Inspired by the success of hierarchical GNNs (Zhang et al.,

node-centric tokenization makes the molecule-language

                                                                           2021; Zang et al., 2023), we transform the original molec-

alignment more challenging, as LLMs have to addition-

                                                                           ular graph G into a hierarchical graph G ′ with motif-level

ally relate the multiple nodes to align the corresponding

                                                                           and molecule-level nodes added in. Specifically, we lever-

texts during the instruction tuning process. Specifically, in

                                                                           age the Breaking of Retrosynthetically Interesting Chemical

molecules, motifs or functional groups usually capture rich

                                                                           Substructures (BRICS) algorithm (Degen et al., 2008)2 to

semantics, and often share many common atoms such as

                                                                           detect and inject a set of k + 1 supernodes, denoted as

carbon, nitrogen, and oxygen (Bohacek et al., 1996). As

                                                                           M = {M(1) , ..., M(k) , M(k+1) }, with k motifs and the

shown in Fig. 2, both the carboxylic acid (“R-COOH”) and

                                                                           original molecule M(k+1) = G. Furthermore, denoting the

the hydroperoxide (“R-OOH”) functional groups all contain                                                          (i)      (i)

                                                                           set of nodes and edges in M(i) as Vm and Em , respec-

two oxygen atoms and a hydrogen atom. For a molecule

                                                                           tively, we augment the original molecular graph G as G ′

with hydroperoxide attached to a scaffold with carbon atoms,

                                                                           with augmented nodes V ′ and edges E ′ :

it would be hard for LLMs to distinguish which functional

group is present in the molecule. Furthermore, due to the

                                                                             V ′ = V ∪ {vm

                                                                                         (1)         (k+1)

                                                                                             , ..., vm     }, E ′ = E ∪ (∪k+1  (i)

                                                                                                                          i=1 Ema ), (6)

loss of positional information in the node-centric tokeniza-

tion (Liang et al., 2023; Cao et al., 2023), the limited expres-                    (i)

                                                                           where vm is the motif super nodes added to the original

sivity of GNNs (Xu et al., 2019) and the positional biases of                             (i)                  (i)

auto-regressive LLMs (Lu et al., 2022), it is more challeng-               molecule, and Ema = ∪u∈V (i) {(u, vm )} are the augmented

                                                                                                      m



ing for LLMs to relate the desired nodes in a motif, which                 edges connecting to the motif super node from nodes within

will lead to subpar molecule-language alignment.                           the corresponding motif. We employ separate VQVAEs for

                                                                           atoms and motifs to learn meaningful code embeddings with

3.2. Motif Hallucination                                                      1

                                                                                https://github.com/rdkit/rdkit/blob/

                                                                           master/Data/FunctionalGroups.txt

To understand the issue of node-centric tokenization                          2

                                                                                Note that HIGHT possesses a high degree of extensibility and

more clearly, we construct a simple benchmark called                       can be augmented by incorporating advanced motif extraction

MotifHallu, to concretize the hallucination of common                      techniques (such as (Zhang et al., 2021)).



                                                                       4

