Automating Chemical Entity Recognition: Creating Your ChemNER Model

I’ve always had a strong interest in chemistry, and it has played a significant role in shaping both my academic and professional journey. As a data professional with a background in chemistry, I’ve found many ways to apply both my scientific and research skills like creativity, curiosity, patience, keen observation, and analysis to data projects. In this article, I’ll walk you through the development of a simple Named Entity Recognition (NER) model that I’ve dubbed ChemNER. This model can identify chemical compounds within text and classify them into categories such as alkanes, alkenes, alkynes, alcohols, aldehydes, ketones, or carboxylic acids.

TL;DR

If you just want to play around with the ChemNER model and/or use the Streamlit app I made, you can access them via the links below:

HuggingFace link: https://huggingface.co/victormurcia/en_chemner

Streamlit AppChemNER Link

Introduction

NER approaches can be generally classified into one of the following 3 categories:

  • Lexicon-based: Define a dictionary of classes and terms

  • Rule-based: Define rules the terms that correspond to each class

  • Machine Learning (ML) — based: Let the model learn the naming rules from a training corpus

Each of these approaches has their strengths and limitations and as always, a more complicated and sophisticated model isn’t always the best approach.

In this case, the lexicon-based approach would be limiting in terms of scope since for every class of compounds we are interested in classifying we’d have to manually define ALL the compounds that fall within that category. In other words, for this approach to be all encompassing you’d need to manually enter every chemical compound for every compound class.

The ML approach could be the most powerful way to go, however, annotating a dataset can be quite laborious (spoiler alert: I’ll end up training a model but I want to show the entire process for educational purposes). Instead, how about we start with some predefined naming rules?