Self-Alignment Pretraining for Biomedical Entity Representations

Fangyu Liu, Ehsan Shareghi, Zaiqiao Meng, Marco Basaldella, Nigel Collier

Introduction

Biomedical entityIn this work, biomedical entity refers to the surface forms of biomedical concepts, which can be a single word (e.g. fever), a compound (e.g. sars-cov-2) or a short phrase (e.g. abnormal retinal vascular development). representation is the foundation for a plethora of text mining systems in the medical domain, facilitating applications such as literature search (Lee et al., 2016), clinical decision making (Roberts et al., 2015) and relational knowledge discovery (e.g. chemical-disease, drug-drug and protein-protein relations, Wang et al. 2018). The heterogeneous naming of biomedical concepts poses a major challenge to representation learning. For instance, the medication Hydroxychloroquine is often referred to as Oxichlorochine (alternative name), HCQ (in social media) and Plaquenil (brand name).

MEL addresses this problem by framing it as a task of mapping entity mentions to unified concepts in a medical knowledge graph.Note that we consider only the biomedical entities themselves and not their contexts, also known as medical concept normalisation/disambiguation in the BioNLP community. The main bottleneck of MEL is the quality of the entity representations Basaldella et al. (2020). Prior works in this domain have adopted very sophisticated text pre-processing heuristics D’Souza and Ng (2015); Kim et al. (2019); Ji et al. (2020); Sung et al. (2020) which can hardly cover all the variations of biomedical names. In parallel, self-supervised learning has shown tremendous success in NLP via leveraging the masked language modelling (MLM) objective to learn semantics from distributional representations (Devlin et al., 2019; Liu et al., 2019). Domain-specific pretraining on biomedical corpora (e.g. BioBert, Lee et al. 2020 and BioMegatron, Shin et al. 2020) have made much progress in biomedical text mining tasks. Nonetheless, representing medical entities with the existing SOTA pretrained MLMs (e.g. PubMedBert, Gu et al. 2020) as suggested in Figure 1 (left) does not lead to a well-separated representation space.

To address the aforementioned issue, we propose to pretrain a Transformer-based language model on the biomedical knowledge graph of UMLS Bodenreider (2004), the largest interlingua of biomedical ontologies. UMLS contains a comprehensive collection of biomedical synonyms in various forms (UMLS 2020AA has 4M+ concepts and 10M+ synonyms which stem from over 150 controlled vocabularies including MeSH, SNOMED CT, RxNorm, Gene Ontology and OMIM).https://www.nlm.nih.gov/research/umls/knowledge_sources/metathesaurus/release/statistics.html We design a self-alignment objective that clusters synonyms of the same concept. To cope with the immense size of UMLS, we sample hard training pairs from the knowledge base and use a scalable metric learning loss. We name our model as Self-aligning pre-trained Bert (SapBert).

Being both simple and powerful, SapBert obtains new SOTA performances across all six MEL benchmark datasets. In contrast with the current systems which adopt complex pipelines and hybrid components (Xu et al., 2020; Ji et al., 2020; Sung et al., 2020), SapBert applies a much simpler training procedure without requiring any pre- or post-processing steps. At test time, a simple nearest neighbour’s search is sufficient for making a prediction. When compared with other domain-specific pretrained language models (e.g. BioBert and SciBert), SapBert also brings substantial improvement by up to 20% on accuracy across all tasks. The effectiveness of the pretraining in SapBert is especially highlighted in the scientific language domain where SapBert outperforms previous SOTA even without fine-tuning on any MEL datasets. We also provide insights on pretraining’s impact across domains and explore pretraining with fewer model parameters by using a recently introduced Adapter module in our training scheme.

Method: Self-Alignment Pretraining

We design a metric learning framework that learns to self-align synonymous biomedical entities. The framework can be used as both pretraining on UMLS, and fine-tuning on task-specific datasets. We use an existing Bert model as our starting point. In the following, we introduce the key components of our framework.

Online Hard Pairs Mining. We use an online hard triplet mining condition to find the most informative training examples (i.e. hard positive/negative pairs) within a mini-batch for efficient training, Figure 2. For biomedical entities, this step can be particularly useful as most examples can be easily classified while a small set of very hard ones cause the most challenge to representation learning.Most of Hydroxychloroquine’s variants are easy: Hydroxychlorochin, Hydroxychloroquine (substance), Hidroxicloroquina, but a few can be very hard: Plaquenil and HCQ. We start from constructing all possible triplets for all names within the mini-batch where each triplet is in the form of (xa,xp,xn)(x_{a},x_{p},x_{n}). Here xax_{a} is called anchor, an arbitrary name in the mini-batch; xpx_{p} a positive match of xax_{a} (i.e. ya=ypy_{a}=y_{p}) and xnx_{n} a negative match of xax_{a} (i.e. yayny_{a}\neq y_{n}). Among the constructed triplets, we select out all triplets that violate the following condition:

where λ\lambda is a pre-set margin. In other words, we only consider triplets with the negative sample closer to the positive sample by a margin of λ\lambda. These are the hard triplets as their original representations were very far from correct. Every hard triplet contributes one hard positive pair (xa,xp)(x_{a},x_{p}) and one hard negative pair (xa,xn)(x_{a},x_{n}). We collect all such positive & negative pairs and denote them as P,N\mathcal{P},\mathcal{N}. A similar but not identical triplet mining condition was used by Schroff et al. (2015) for face recognition to select hard negative samples. Switching-off this mining process, causes a drastic performance drop (see Table 2).

where α,β\alpha,\beta are temperature scales; ϵ\epsilon is an offset applied on the similarity matrix; Pi,Ni\mathcal{P}_{i},\mathcal{N}_{i} are indices of positive and negative samples of the anchor ii.We explored several loss functions such as InfoNCE (Oord et al., 2018), NCA loss (Goldberger et al., 2005), simple cosine loss (Phan et al., 2019), max-margin triplet loss (Basaldella et al., 2020) but found our choice is empirically better. See Section B.2 for comparison.

While the first term in Eq. 2 pushes negative pairs away from each other, the second term pulls positive pairs together. This dynamic allows for a re-calibration of the alignment space using the semantic biases of synonymy relations. The MS loss leverages similarities among and between positive and negative pairs to re-weight the importance of the samples. The most informative pairs will receive more gradient signals during training and thus can better use the information stored in data.

Experiments and Discussions

Data Preparation Details for UMLS Pretraining. We download the full release of UMLS 2020AA version.https://download.nlm.nih.gov/umls/kss/2020AA/umls-2020AA-full.zip We then extract all English entries from the MRCONSO.RFF raw file and convert all entity names into lowercase (duplicates are removed). Besides synonyms defined in MRCONSO.RFF, we also include tradenames of drugs as synonyms (extracted from MRREL.RRF). After pre-processing, a list of 9,712,959 (name, CUI) entries is obtained. However, random batching on this list can lead to very few (if not none) positive pairs within a mini-batch. To ensure sufficient positives present in each mini-batch, we generate offline positive pairs in the format of (name1, name2, CUI) where name1 and name2 have the same CUI label. This can be achieved by enumerating all possible combinations of synonym pairs with common CUIs. For balanced training, any concepts with more than 50 positive pairs are randomly trimmed to 50 pairs. In the end we obtain a training list with 11,792,953 pairwise entries.

UMLS Pretraining Details. During training, we use AdamW (Loshchilov and Hutter, 2018) with a learning rate of 2e-5 and weight decay rate of 1e-2. Models are trained on the prepared pairwise UMLS data for 1 epoch (approximately 50k iterations) with a batch size of 512 (i.e., 256 pairs per mini-batch). We train with Automatic Mixed Precision (AMP)https://pytorch.org/docs/stable/amp.html provided in PyTorch 1.7.0. This takes approximately 5 hours on our machine (configurations specified in Section B.4). For other hyper-parameters used, please view Section C.2.

Evaluation Data and Protocol. We experiment on 6 different English MEL datasets: 4 in the scientific domain (NCBI, Doğan et al. 2014; BC5CDR-c and BC5CDR-d, Li et al. 2016; MedMentions, Mohan and Li 2018) and 2 in the social media domain (COMETA, Basaldella et al. 2020 and AskAPatient, Limsopatham and Collier 2016). Descriptions of the datasets and their statistics are provided in Appendix A. We report Acc@1 and Acc@5 (denoted as @1@1 and @5@5) for evaluating performance. In all experiments, SapBert denotes further pretraining with our self-alignment method on UMLS. At the test phase, for all SapBert models we use nearest neighbour search without further fine-tuning on task data (unless stated otherwise). Except for numbers reported in previous papers, all results are the average of five runs with different random seeds.

Fine-Tuning on Task Data. The red rows in Table 1 are results of models (further) fine-tuned on the training sets of the six MEL datasets. Similar to pretraining, a positive pair list is generated through traversing the combinations of mention and all ground truth synonyms where mentions are from the training set and ground truth synonyms are from the reference ontology. We use the same optimiser and learning rates but train with a batch size of 256 (to accommodate the memory of 1 GPU). On scientific language datasets, we train for 3 epochs while on AskAPatient and COMETA we train for 15 and 10 epochs respectively. For BioSyn on social media language datasets, we empirically found that 10 epochs work the best. Other configurations are the same as the original BioSyn paper.

2 Main Results and Analysis

*Bert + SapBert (Table 1, top). We illustrate the impact of SapBert pretraining over 7 existing Bert-based models (*Bert = {BioBert, PubMedBert, …}). SapBert obtains consistent improvement over all *Bert models across all datasets, with larger gains (by up to 31.0% absolute Acc@1 increase) observed in the social media domain. While SciBert is the leading model before applying SapBert, PubMedBert+SapBert performs the best afterwards.

SapBert vs. SOTA (Table 1, bottom). We take PubMedBert+SapBert (w/wo fine-tuning) and compare against various published SOTA results (see Section C.1 for a full listing of 10 baselines) which all require task supervision. For the scientific language domain, the SOTA is BioSyn (Sung et al., 2020). For the social media domain, the SOTA are Basaldella et al. (2020) and Gen-Rank (Xu et al., 2020) on COMETA and AskAPatient respectively. All these SOTA methods combine Bert with heuristic modules such as tf-idf, string matching and information retrieval system (i.e. Apache Lucene) in a multi-stage manner.

Measured by Acc@1, SapBert achieves new SOTA with statistical significance on 5 of the 6 datasets and for the dataset (BC5CDR-c) where SapBert is not significantly better, it performs on par with SOTA (96.5 vs. 96.6). Interestingly, on scientific language datasets, SapBert outperforms SOTA without any task supervision (fine-tuning mostly leads to overfitting and performance drops). On social media language datasets, unsupervised SapBert lags behind supervised SOTA by large margins, highlighting the well-documented complex nature of social media language (Baldwin et al., 2013; Limsopatham and Collier, 2015, 2016; Basaldella et al., 2020; Tutubalina et al., 2020). However, after fine-tuning on the social media datasets (using the MS loss introduced earlier), SapBert outperforms SOTA significantly, indicating that knowledge acquired during the self-aligning pretraining can be adapted to a shifted domain without much effort.

The Adapter Variant. As an option for parameter efficient pretraining, we explore a variant of SapBert using a recently introduced training module named Adapter (Houlsby et al., 2019). While maintaining the same pretraining scheme with the same SapBert online mining + MS loss, instead of training from the full model of PubMedBert, we insert new Adapter layers between Transformer layers of the fixed PubMedBert, and only train the weights of these Adapter layers. In our experiments, we use the enhanced Adapter configuration by Pfeiffer et al. (2020). We include two variants where trained parameters are 13.22% and 1.09% of the full SapBert variant. The Adapter variant of SapBert achieves comparable performance to full-model-tuning in scientific datasets but lags behind in social media datasets, Table 1. The results indicate that more parameters are needed in pretraining for knowledge transfer to a shifted domain, in our case, the social media datasets.

The Impact of Online Mining (Equation 1). As suggested in Table 2, switching off the online hard pairs mining procedure causes a large performance drop in @1@1 and a smaller but still significant drop in @5@5. This is due to the presence of many easy and already well-separated samples in the mini-batches. These uninformative training examples dominated the gradients and harmed the learning process.

Integrating SapBert in Existing Systems. SapBert can be easily inserted into existing Bert-based MEL systems by initialising the systems with SapBert pretrained weights. We use the SOTA scientific language system, BioSyn (originally initialised with BioBert weights), as an example and show the performance is boosted across all datasets (last two rows, Table 1).

Conclusion

We present SapBert, a self-alignment pretraining scheme for learning biomedical entity representations. We highlight the consistent performance boost achieved by SapBert, obtaining new SOTA in all six widely used MEL benchmarking datasets. Strikingly, without any fine-tuning on task-specific labelled data, SapBert already outperforms the previous supervised SOTA (sophisticated hybrid entity linking systems) on multiple datasets in the scientific language domain. Our work opens new avenues to explore for general domain self-alignment (e.g. by leveraging knowledge graphs such as DBpedia). We plan to incorporate other types of relations (i.e., hypernymy and hyponymy) and extend our model to sentence-level representation learning. In particular, our ongoing work using a combination of SapBert and Adapter is a promising direction for tackling sentence-level tasks.

Acknowledgements

We thank the three reviewers and the Area Chair for their insightful comments and suggestions. FL is supported by Grace & Thomas C.H. Chan Cambridge Scholarship. NC and MB would like to acknowledge funding from Health Data Research UK as part of the National Text Analytics project.

References

Appendix A Evaluation Datasets Details

We divide our experimental datasets into two categories (1) scientific language datasests where the data is extracted from scientific papers and (2) social media language datasets where the data is coming from social media forums like Reddit.com. For an overview of the key statistics, see Table 3.

is a corpus containing 793 fully annotated PubMed abstracts and 6,881 mentions. The mentions are mapped into the MEDIC dictionary (Davis et al., 2012). We denote this dataset as “NCBI” in our experiments.

BC5CDR (Li et al., 2016)

consists of 1,500 PubMed articles with 4,409 annotated chemicals, 5,818 diseases and 3,116 chemical-disease interactions. The disease mentions are mapped into the MEDIC dictionary like the NCBI disease corpus. The chemical mentions are mapped into the Comparative Toxicogenomics Database (CTD) (Davis et al., 2019) chemical dictionary. We denote the disease and chemical mention sets as “BC5CDR-d” and “BC5CDR-c” respectively. For NCBI and BC5CDR we use the same data and evaluation protocol by Sung et al. (2020).https://github.com/dmis-lab/BioSyn

MedMentions (Mohan and Li, 2018)

is a very-large-scale entity linking dataset containing over 4,000 abstracts and over 350,000 mentions linked to UMLS 2017AA. According to Mohan and Li (2018), training TaggerOne (Leaman and Lu, 2016), a very popular MEL system, on a subset of MedMentions require >900 GB of RAM. Its massive number of mentions and more importantly the used reference ontology (UMLS 2017AA has 3M+ concepts) make the application of most MEL systems infeasible. However, through our metric learning formulation, SapBert can be applied on MedMentions with minimal effort.

A.2 Social-Media Language Datasets

includes 17,324 adverse drug reaction (ADR) annotations collected from askapatient.com blog posts. The mentions are mapped to 1,036 medical concepts grounded onto SNOMED-CT (Donnelly, 2006) and AMT (the Australian Medicines Terminology). For this dataset, we follow the 10-fold evaluation protocol stated in the original paper.https://zenodo.org/record/55013

COMETA (Basaldella et al., 2020)

is a recently released large-scale MEL dataset that specifically focuses on MEL in the social media domain, containing around 20k medical mentions extracted from health-related discussions on reddit.com. Mentions are mapped to SNOMED-CT. We use the “stratified (general)” split and follow the evaluation protocol of the original paper.https://www.siphs.org/corpus

Appendix B Model & Training Details

We list all the versions of Bert models used in this study, linking to the specific versions in Table 5. Note that we exhaustively tried all official variants of the selected models and the best performing ones are chosen. All Bert models refer to the BertBase{}_{\text{Base}} architecture in this paper.

B.2 Comparing Loss Functions

We use COMETA (zeroshot general) as a benchmark for selecting learning objectives. Note that this split of COMETA is different from the stratified-general split used in Table 4. It is very challenging (so easy to see the difference of the performance) and also does not directly affect the model’s performance on other datasets. The results are listed in Table 6. Note that online mining is switched on for all models here.

The cosine loss was used by Phan et al. (2019) for learning UMLS synonyms for LSTM models. The max-margin triplet loss was used by Basaldella et al. (2020) for training MEL models. A very similar (though not identical) hinge-loss was used by Schumacher et al. (2020) for clinical concept linking. InfoNCE has been very popular in self-supervised learning and contrastive learning (Oord et al., 2018; He et al., 2020). Lifted-Structure loss (Oh Song et al., 2016) and NCA loss (Goldberger et al., 2005) are two very classic metric learning objectives. Multi-Similarity loss (Wang et al., 2019) and Circle loss (Sun et al., 2020) are two recently proposed metric learning objectives and have been considered as SOTA on large-scale visual recognition benchmarks.

B.3 Details of Adapters

In Table 7 we list number of parameters trained in the three Adapter variants along with full-model-tuning for easy comparison.

B.4 Hardware Configurations

All our experiments are conducted on a server with specifications listed in Table 8.

Appendix C Other Details

The full table of supervised baseline models is provided in Table 4.

C.2 Hyper-Parameters Search Scope

Table 9 lists hyper-parameter search space for obtaining the set of used numbers. Note that the chosen hyper-parameters yield the overall best performance but might be sub-optimal on any single dataset. Also, we balanced the memory limit and model performance.

C.3 A High-Resolution Version of Figure 1

We show a clearer version of t-SNE embedding visualisation in Figure 3.