Revolutionising Ontology Engineering with Deep Learning: An Introduction to DeepOnto

Yuan He
4 min readAug 5, 2023

--

In the realm of Artificial Intelligence (AI), ontology engineering plays a pivotal role in structuring knowledge and facilitating semantic interoperability. In this article, we introduce DeepOnto, a Python package that synergises ontology engineering with deep learning and especially language models, offering a convenient toolkit for researchers and developers alike.

Documentation: https://krr-oxford.github.io/DeepOnto/

GitHub Repository: https://github.com/KRR-Oxford/DeepOnto

What is an Ontology?

In the context of AI, an ontology is a formal representation of knowledge within a domain. It is defined by a set of logical axioms that represent semantic relationships between concepts. Ontologies provide a structured framework that enables not only the sharing and re-use of data but also automated reasoning about it. Due to the underlying logic formalism, ontologies are suitable for modelling conceptual knowledge, and thus are commonly adopted in life science and biomedical domains.

The figure below depicts a snapshot of the Health Lifestyle Support (HeLis) ontology, where several food-related concepts are presented in ellipses, instances of concepts are presented in single-corner-snipped rectangles, and attributes of concepts are presented in rectangles. The edges between shapes represent different semantic relationships such as subsumption (rdfs:subClassOf), membership (rdfs:type), and annotation (e.g., vc:unit). This example shows that ontologies are equipped with a highly expressive syntax for knowledge representation.

Figure 1: Fragment of the HeLis ontology (Source: Chen et al., “OWL2Vec*: Embedding of OWL Ontologies”, Machine Learning, 2021).

However, constructing and curating ontologies can be a complex task. This is where DeepOnto comes into play.

What is DeepOnto?

DeepOnto is a Python package designed to provide building blocks for processing ontologies, implementing deep learning models, constructing resources, and conducting evaluations for various ontology engineering purposes. It leverages the OWL API version 4 for ontology processing and Pytorch for the deep learning framework. DeepOnto comes packed with a suite of features that make ontology engineering a breeze.

DeepOnto can be installed from PyPI or directly from the GitHub repository. See the installation guide here.

Figure 2. An illustration of DeepOnto’s architecture (Source: He et al., “DeepOnto: A Python Package for Ontology Engineering with Deep Learning”, preprint under review at Semantic Web Journal, 2023)

Ontology Processing

The base class of DeepOnto is Ontology, which serves as the main entry point for introducing the OWLAPI’s features. This includes accessing ontology entities, querying for ancestor/descendent (and parent/child) concepts, deleting entities, modifying axioms, retrieving annotations, and so on. A local ontology file (e.g., pizza ontology) can be easily loaded using the following code:

from deeponto.onto import Ontology

onto = Ontology(ontology_file_path) # ended with .owl, .ttl, etc.

We can then access the sets of named concepts and properties:

onto.owl_classes  # concepts
onto.owl_object_properties # object properties
onto.owl_data_properties # data properties

We can also access a concept’s annotations (e.g., rdfs:label) through:

some_concept = onto.owl_classes[0]  # the first concept
onto.get_owl_object_annotations(some_concept, annotation_property_iri="http://www.w3.org/2000/01/rdf-schema#label") # rdfs:label

Or build an annotation index for all concepts using:

annotation_index, used_annotation_properties = onto.build_annotation_index()
annotation_index["some_concept_iri"] # access concept annotations through IRI

Click here to see full usage of Ontology .

Based on the base Ontology class, we further implemented several ontology processing modules that are commonly required in the development of deep learning-based ontology engineering solutions, including the following:

  • Ontology Reasoning (deeponto.onto.OntologyReasoner): Each instance of Ontology has a reasoner (onto.reasoner) as its attribute, used for conducting reasoning activities such as obtaining inferred subsumers and subsumees, as well as checking entailment and consistency.
  • Ontology Pruning (deeponto.onto.OntologyPruner): Pruning refers to extracting a sub-ontology from the input ontology to meet certain criteria.
  • Ontology Verbalisation (deeponto.onto.OntologyVerbaliser): Verbalisation refers to automatically transform a complex logical expression into a textual sentence based on entity names or labels available in the ontology. This is particularly useful for preparing textual inputs for language models. We made available a tutorial for using the verbaliser.
  • Ontology Projection(deeponto.onto.OntologyProjector): Projection refers to transform ontology axioms into a set of corresponding RDF triples so that we can view an ontology as a graph.
  • Ontology Normalisation(deeponto.onto.OntologyNormaliser): Normalisation refers to transform ontology axioms into normalised forms. Such process is often required in geometric ontology embeddings.

Tools and Resources

DeepOnto not only provides an API for ontology processing, but also a range of tools and resources built upon its API. Currently, DeepOnto incorporates the following:

  • BERTMap: A BERT-based ontology matching (OM) system, with a focus of named concept equivalence. It successfully integrates the masked language model BERT into the OM pipeline. [tutorial]
  • Bio-ML: An machine learning-friendly OM resource that has been used in the Bio-ML track of the OAEI. The dataset construction and evaluation methods are implemented in DeepOnto. [tutorial]
  • BERTSubs: A sibling system of BERTMap focusing on intra-ontology subsumption prediction (ontology completion), and inter-ontology subsumption alignment (OM). [tutorial]
  • OntoLAMA: A set of language model probing datasets for ontology subsumption inference. The corresponding probing method can also be used for subsumption-based ontology completion. [tutorial]

Conclusion

This article provides a brief introduction to DeepOnto. For more detailed information, you can visit the documentation and the Github repository.

Whether you’re a researcher or a developer looking to playing around with ontologies or implementing deep learning models for ontology engineering, DeepOnto offers a comprehensive toolkit to support your work.

Photo by James Toose on Unsplash. The cute owl is also a standardised ontology language!

--

--

Yuan He

PhD Student in Computer Science (AI/KRR/NLP/ML) at University of Oxford