DeepOnto: A Python package for ontology engineering with deep learning

Yuan He, Jiaoyan Chen, Hang Dong, Ian Horrocks, Carlo Allocca, Taehun Kim, Brahmananda Sapkota

TL;DR

DeepOnto is a new Python package that bridges the gap between symbolic knowledge representation (ontologies) and neural networks (deep learning). By providing a "Pythonic" wrapper for the industry-standard Java OWL API and adding specialized tools for language model integration, it enables researchers to build hybrid AI systems that combine formal logic with the flexibility of deep learning.

What Problem Does This Paper Address?

For decades, ontologies—formal, structured specifications of domain knowledge—have been the backbone of fields like bioinformatics and the Semantic Web. However, the ecosystem for ontology engineering is largely built on Java (e.g., OWL API, Jena). In contrast, the modern deep learning (DL) revolution, powered by libraries like PyTorch and TensorFlow, is almost exclusively Python-based.

This "language barrier" creates a significant hurdle for researchers trying to use Large Language Models (LLMs) or Graph Neural Networks (GNNs) to improve ontologies. Beyond just the programming language, traditional ontology tools aren't designed to transform complex logical axioms into the text or graph formats that DL models require. DeepOnto addresses this by providing a unified Python platform that handles both the rigorous logic of ontologies and the data needs of deep learning.

Methods

DeepOnto is structured into two main layers: a core processing module and a suite of high-level tools for specific tasks.

Core Processing Module

To ensure reliability, DeepOnto uses JPype to interface directly with the Java-based OWL API. It wraps these features into a cohesive Python interface and adds several advanced capabilities:

  • Reasoning: Integrated support for reasoners like HermiT and ELK to check for logical consistency and infer new knowledge.
  • Verbalization: A recursive algorithm that translates complex logical expressions into natural language sentences. For example, it can turn a complex axiom about food products into the human-readable string: "food product that derives from invertebrate animal or vertebrate animal" (see Figure 2).
  • Pruning: An algorithm to extract smaller, semantically consistent sub-ontologies from massive datasets, making them manageable for DL training.
  • Projection: Converting complex OWL axioms into simplified RDF triples, which are much easier for graph-based algorithms to process.

DeepOnto Architecture *Fig.

  1. The architecture of DeepOnto, showing the core processing module supporting higher-level DL tools.*

High-Level Tools

Building on the core, the authors include several specialized systems:

  • BERTMap: Uses BERT to find equivalent concepts across different ontologies.
  • BERTSubs: Predicts "is-a" (subsumption) relationships between concepts.
  • OntoLAMA: A framework for probing how well language models actually understand ontological knowledge.

Datasets

The paper introduces and utilizes several key benchmarks:

  • Bio-ML: A comprehensive new benchmark for biomedical ontology matching. It includes datasets derived from major sources like SNOMED-CT, FMA, and NCIT. Unlike older benchmarks, Bio-ML supports both equivalence and subsumption matching and provides dedicated splits for training, validation, and testing.
  • OntoLAMA: A collection of datasets specifically designed for probing language models on their ability to perform subsumption inference.
  • Samsung Digital Health Use Case: A real-world dataset aligning NHS conditions to the Disease Ontology (DOID).
Bio-ML Dataset Statistics

Key Insights and Ideas

  • Logic-to-Text Translation: One of the most powerful features is the recursive verbalizer. By turning abstract logic into natural language, DeepOnto allows pre-trained LMs to "read" an ontology, leveraging the vast linguistic knowledge they acquired during pre-training to solve logical tasks.
  • Maintaining Hierarchy During Pruning: When reducing the size of an ontology, it's easy to break the "is-a" chain. DeepOnto’s pruning algorithm (illustrated in Figure 2) automatically reconstructs these links, ensuring the resulting sub-ontology remains logically sound.
  • Hybrid AI in Practice: The Samsung use case demonstrates that while DL is great for matching concepts, symbolic ontologies are still necessary for providing the explainability and rigorous reasoning required in health coaching.

Pruning and Verbalization Examples *Fig.

  1. Left: Pruning while preserving hierarchy. Right: Recursive verbalization of a complex concept.*

Key Results

  • OAEI 2022 Bio-ML Track: In the Ontology Alignment Evaluation Initiative, ML-based systems (like BERTMap) generally outperformed traditional lexical-matching systems.
  • Subsumption Matching: The authors found that traditional systems struggle with predicting "is-a" relationships because they rely too heavily on name similarity. DL models, however, proved much more robust at capturing these deeper semantic links.
  • Real-World Utility: In the Samsung Digital Health Coaching case, BERTMap achieved a promising F-score of 0.874 when aligning medical concepts, significantly outperforming simple string-matching baselines.

Limitations and Future Work

While DeepOnto is a major step forward, the authors note a few areas for growth:

  • Relational Knowledge: The current version is heavily focused on language models and complex logical axioms. Future versions aim to better support knowledge graphs that consist primarily of simple relational facts.
  • Automated Construction: The team plans to add features for "concept insertion"—automatically placing a new concept derived from text into the correct spot in an existing ontology hierarchy.
  • Broader DL Support: While LMs are the current focus, expanding support for specialized ontology embedding methods (like OWL2Vec*) is on the roadmap.

Summary updated

BibTeX
@inproceedings{he2024deeponto,
  author = {Yuan He and Jiaoyan Chen and Hang Dong and Ian Horrocks and Carlo Allocca and Taehun Kim and Brahmananda Sapkota},
  title = {{DeepOnto: A Python package for ontology engineering with deep learning}},
  booktitle = {Semantic Web},
  year = {2024},
  url = {https://openreview.net/forum?id=LWEBR4ESKX},
}
Figure