  Reference ontologies provide a shared vocabulary and knowledge resource for
their domain. Manual construction enables them to maintain a high quality,
allowing them to be widely accepted across their community. However, the manual
development process does not scale for large domains. We present a new
methodology for automatic ontology extension and apply it to the ChEBI
ontology, a prominent reference ontology for life sciences chemistry. We
trained a Transformer-based deep learning model on the leaf node structures
from the ChEBI ontology and the classes to which they belong. The model is then
capable of automatically classifying previously unseen chemical structures. The
proposed model achieved an overall F1 score of 0.80, an improvement of 6
percentage points over our previous results on the same dataset. Additionally,
we demonstrate how visualizing the model's attention weights can help to
explain the results by providing insight into how the model made its decisions.
