Ontolearn-A Framework for Large-scale OWL Class Expression Learning in Python

Caglar Demir, Alkid Baci, N'Dah Jean Kouagou, Leonie Nora Sieger, Stefan Heindorf, Simon Bin, Lukas Blübaum, Alexander Bigerl, Axel-Cyrille Ngonga Ngomo

TL;DR

Ontolearn is an open-source Python framework designed for learning explainable OWL (Web Ontology Language) class expressions over massive knowledge graphs. By combining classic symbolic reasoning with modern neuro-symbolic models and LLM-powered natural language translation, it provides a scalable, production-ready alternative to outdated Java-based tooling.

What Problem Does This Paper Address?

Explainable AI on Web-scale data requires extracting human-readable rules from massive Resource Description Framework (RDF) knowledge graphs (KGs). Historically, DL-Learner (a Java framework) was the gold standard for learning OWL class expressions—essentially finding logical descriptions that define a specific group of entities.

However, DL-Learner has been unmaintained since 2021, lacks support for modern neuro-symbolic and deep learning approaches, and struggles to scale to graphs with millions of triples. Ontolearn fills this gap by providing a modern, scalable, and actively maintained Python ecosystem for description logic concept learning.

Methods

Ontolearn unifies several distinct components into a cohesive software architecture:

Ontolearn architecture showing top-level and sub-components.
  • Algorithm Suite: It implements nine state-of-the-art symbolic, neuro-symbolic, and deep learning algorithms (including EvoLearner, DRILL, NCES, and ROCES) alongside optimized Python rewrites of classic DL-Learner algorithms (CELOE, OCEL).
  • Scalability via SPARQL: Instead of forcing massive ontologies ($>10^8$ triples) entirely into RAM, Ontolearn can map OWL class expressions directly to SPARQL queries. This allows it to interface seamlessly with remote, high-performance triplestores like Tentris.
  • Reasoning & Sampling: It leverages the Owlapy library to interface with standard OWL reasoners (such as Hermit and Pellet) and integrates graph sampling techniques (OntoSample) to accelerate training times.
  • LLM Verbalization: To make learned description logic expressions accessible to non-experts, Ontolearn integrates Large Language Models (like Llama and Mistral) to translate formal logic into natural language sentences.

Datasets

As a software framework paper, the authors focus on the library's capabilities rather than introducing a new benchmark dataset. However, they demonstrate its functionality using the standard Family knowledge base to illustrate supervised class expression learning (e.g., finding the logical rules that define a concept like "Married Female"). The framework is explicitly built to scale up to large-scale industrial ontologies containing over 100 million triples.

Key Insights and Ideas

  • Neuro-Symbolic Convergence: Ontolearn proves that symbolic logic learning doesn't have to be isolated from deep learning; it natively hosts hybrid models like DRILL and NCES that use neural networks to guide symbolic search.
  • Bypassing the Memory Bottleneck: By compiling OWL expressions into SPARQL queries on the fly, the framework shifts the heavy lifting of instance retrieval to optimized triplestores, solving a classic scalability bottleneck in description logic learning.
  • Closing the Usability Gap: Formal logic (e.g., $\text{Female} \sqcap (\exists\text{married}.\top)$) is notoriously difficult for humans to parse. Using LLMs as a translation layer makes the output of symbolic AI instantly understandable ("A female who is married"), as shown in their family tree example:
A partial visualization of the Family knowledge base along with a learning problem.

Key Results

  • Software Maturity: The framework consists of approximately 20,000 lines of Python code, features 95% test coverage (156 unit/regression tests), and includes 26 example scripts to guide new users.
  • Adoption: Ontolearn has already surpassed 26,000 downloads via PyPI and is released under the permissive MIT license.
  • Ecosystem Integration: It has already been successfully applied in industrial Industry 4.0 settings and integrated into complementary libraries like EDGE (explaining Graph Neural Networks) and AutoCL (AutoML for concept learning).

Limitations and Future Work

Because this is a short system description paper, the authors do not deeply detail limitations. However, a notable challenge in this domain is that performance remains tightly bound to the efficiency of the underlying OWL reasoners and triplestores when dealing with highly complex ontologies. The authors note that future work includes continuing to extend the framework with novel concept learners and providing built-in code to easily launch Ontolearn as a web service.

Summary updated

BibTeX
@article{demir2025ontolearn,
  author = {Caglar Demir and Alkid Baci and N'Dah Jean Kouagou and Leonie Nora Sieger and Stefan Heindorf and Simon Bin and Lukas Blübaum and Alexander Bigerl and Axel-Cyrille Ngonga Ngomo},
  title = {{Ontolearn-A Framework for Large-scale OWL Class Expression Learning in Python}},
  journal = {J. Mach. Learn. Res.},
  year = {2025},
}
Figure