ontolearner

OntoLearner: A Modular Python Library for Ontology Learning with LLMs https://pypi.org/project/OntoLearner/

https://github.com/sciknoworg/ontolearner

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary

Keywords

benchmarking ontologies ontology-engineering ontology-learning python-library text2onto
Last synced: 4 months ago · JSON representation ·

Repository

OntoLearner: A Modular Python Library for Ontology Learning with LLMs https://pypi.org/project/OntoLearner/

Basic Info
Statistics
  • Stars: 9
  • Watchers: 2
  • Forks: 1
  • Open Issues: 9
  • Releases: 0
Topics
benchmarking ontologies ontology-engineering ontology-learning python-library text2onto
Created 12 months ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

OntoLearner Logo

OntoLearner: A Modular Python Library for Ontology Learning with LLMs

[![PyPI version](https://badge.fury.io/py/OntoLearner.svg)](https://badge.fury.io/py/OntoLearner) [![PyPI Downloads](https://static.pepy.tech/badge/ontolearner)](https://pepy.tech/projects/ontolearner) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Hugging Face Collection](https://img.shields.io/badge/🤗HuggingFace-Collection-blue)](https://huggingface.co/collections/SciKnowOrg/) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Documentation Status](https://app.readthedocs.org/projects/ontolearner/badge/)](https://ontolearner.readthedocs.io/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](MAINTANANCE.md) [![DOI](https://zenodo.org/badge/913867999.svg)](https://doi.org/10.5281/zenodo.15399773)

OntoLearner is a modular and extensible architecture designed to support ontology learning and reuse. The conceptual and functional architecture of OntoLearner is shown as following. The framework comprises three core components—Ontologizers, Learning Tasks, and Learner Models—structured to enable reusable and customizable ontology engineering workflows.

🧪 Installation

OntoLearner is available on PyPI and you can install using pip:

bash pip install ontolearner

Next, verify the installation: ```python import ontolearner

print(ontolearner.version) ```

Please refer to Installation page for further options.

🔗 Essential Resources

| Resource | Info | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 📚 OntoLearner Documentation | OntoLearner's extensive documentation website. | | 🤗 Datasets on Hugging Face | Access curated, machine-readable ontologies. | | Quick Tour on OntoLearner Open In Colab version=1.2.1 | OntoLearner hands-on Colab tutorials. | | 🚀 Quickstart | Get started quickly with OntoLearner’s main features and workflow. | | 🕸️ Learning Tasks | Explore supported ontology learning tasks like LLMs4OL Paradigm tasks and Text2Onto. | | | 🧠 Learner Models | Browse and configure various learner models, including LLMs, Retrieval, or RAG approaches. | | 📚 Ontologies Documentations | Review benchmark ontologies and datasets used for evaluation and training. | | 🧩 How to work with Ontologizer? | Learn how to modularize and preprocess ontologies using the Ontologizer module. |

🚀 Quick Tour

Get started with OntoLearner in just a few lines of code. This guide demonstrates how to initialize ontologies, load datasets, and train an LLM-assisted learner for ontology engineering tasks.

Basic Usage - Automatic Download from Hugging Face: ```python from ontolearner import Wine

1. Initialize an ontologizer from OntoLearner

ontology = Wine()

2. Load the ontology automatically from HuggingFace

ontology.load()

3. Extract the learning task dataset

data = ontology.extract() ```

To see the ontology metadata you can print the ontology: python print(ontology)

Now, explore 150+ ready-to-use ontologies or read on how to work with ontologizers.

Learner Models:

```python from ontolearner import AutoRetrieverLearner, AgrO, traintestsplit, evaluation_report

1. Programmatic import of an ontology

ontology = AgrO() ontology.load()

2. Load tasks datasets

ontological_data = ontology.extract()

3. Split into train and test sets

traindata, testdata = traintestsplit(ontologicaldata, testsize=0.2, random_state=42)

4. Initialize Learner

task = 'non-taxonomic-re' retlearner = AutoRetrieverLearner(topk=5) retlearner.load(modelid='sentence-transformers/all-MiniLM-L6-v2')

5. Fit the model to training data and do the predict

retlearner.fit(traindata, task=task) predicts = retlearner.predict(testdata, task=task)

6. Evaluation

truth = retlearner.tasksgroundtruthformer(data=testdata, task=task) metrics = evaluationreport(ytrue=truth, ypred=predicts, task=task) print(metrics) ``` Other learners: * LLM-Based Learner * RAG-Based Learner

LearnerPipeline: The OntoLearner also offers a streamlined LearnerPipeline class that simplifies the entire process of initializing, training, predicting, and evaluating a RAG setup into a single call.

```python

Import core components from the OntoLearner library

from ontolearner import LearnerPipeline, AgrO, traintestsplit

Load the AgrO ontology, which includes structured agricultural knowledge

ontology = AgrO() ontology.load() # Load ontology data (e.g., entities, relations, metadata)

Extract relation instances from the ontology and split them into training and test sets

traindata, testdata = traintestsplit( ontology.extract(), # Extract annotated (head, tail, relation) triples testsize=0.2, # 20% for evaluation randomstate=42 # Ensures reproducible splits )

Initialize the learning pipeline using a dense retriever

pipeline = LearnerPipeline( retrieverid='sentence-transformers/all-MiniLM-L6-v2', # Hugging Face model ID for retrieval batchsize=10, # Number of samples to process per batch (if batching is enabled internally) top_k=5 # Retrieve top-5 most relevant support instance per query )

Run the pipeline on the training and test data

The pipeline performs: fit() → predict() → evaluate() in sequence

outputs = pipeline( traindata=traindata, testdata=testdata, evaluate=True, # If True, computes precision, recall, and F1-score task='non-taxonomic-re' # Specifies that we are doing non-taxonomic relation prediction )

Print the evaluation metrics (precision, recall, F1)

print("Metrics:", outputs['metrics'])

Print the total elapsed time for training and evaluation

print("Elapsed time:", outputs['elapsed_time'])

Print the full output dictionary (includes predictions)

print(outputs) ```

⭐ Contribution

We welcome contributions to enhance OntoLearner and make it even better! Please review our contribution guidelines in CONTRIBUTING.md before getting started. You are also welcome to assist with the ongoing maintenance by referring to MAINTENANCE.md. Your support is greatly appreciated.

If you encounter any issues or have questions, please submit them in the GitHub issues tracker.

💡 Acknowledgements

If you find this repository helpful or use OntoLearner in your work or research, feel free to cite our publication:

bibtex @inproceedings{babaei2023llms4ol, title={LLMs4OL: Large language models for ontology learning}, author={Babaei Giglou, Hamed and D’Souza, Jennifer and Auer, S{\"o}ren}, booktitle={International Semantic Web Conference}, pages={408--427}, year={2023}, organization={Springer} } or: bibtex @software{babaei_giglou_2025_15399783, author = {Babaei Giglou, Hamed and D'Souza, Jennifer and Aioanei, Andrei and Mihindukulasooriya, Nandana and Auer, Sören}, title = {OntoLearner: A Modular Python Library for Ontology Learning with LLMs}, month = may, year = 2025, publisher = {Zenodo}, version = {v1.3.0}, doi = {10.5281/zenodo.15399783}, url = {https://doi.org/10.5281/zenodo.15399783}, }


This software is archived in Zenodo under the DOI DOI and is licensed under License: MIT.

Owner

  • Name: SciKnowOrg
  • Login: sciknoworg
  • Kind: organization
  • Email: sciknoworg@gmail.com
  • Location: Germany

Scientific Knowledge Organization (SKO group or SciKnowOrg group)

Citation (CITATION.cff)

cff-version: 1.2.0
title: "OntoLearner: A Modular Python Library for Ontology Learning with LLMs"
message: If you use this software, please cite it using the metadata from this file.
type: software
authors:
  - given-names: Hamed
    family-names: Babaei Giglou
    email: hamed.babaei@tib.eu
    affiliation: TIB Leibniz Information Centre for Science and Technology
  - given-names: Jennifer
    family-names: D'Souza
    email: Jennifer.DSouza@tib.eu
    affiliation: TIB Leibniz Information Centre for Science and Technology
  - given-names: Andrei
    family-names: Aioanei
    email: Andrei.Aioanei@tib.eu
    affiliation: TIB Leibniz Information Centre for Science and Technology
  - given-names: Nandana
    family-names: Mihindukulasooriya
    email: nandana@ibm.com
    affiliation: IBM Research
  - given-names: Sören
    family-names: Auer
    email: auer@tib.eu
    affiliation: TIB Leibniz Information Centre for Science and Technology
url: 'https://github.com/sciknoworg/OntoLearner'
keywords:
  - Ontology learning
  - Toolkit
  - Generative artificial intelligence
  - Large Language Models
  - Text-to-ontology
license: MIT
version: 1.4.2
date-released: '2025'

GitHub Events

Total
  • Fork event: 1
  • Create event: 46
  • Issues event: 161
  • Release event: 14
  • Watch event: 6
  • Delete event: 41
  • Member event: 1
  • Issue comment event: 59
  • Public event: 1
  • Push event: 263
  • Pull request review comment event: 72
  • Pull request review event: 17
  • Pull request event: 70
Last Year
  • Fork event: 1
  • Create event: 46
  • Issues event: 161
  • Release event: 14
  • Watch event: 6
  • Delete event: 41
  • Member event: 1
  • Issue comment event: 59
  • Public event: 1
  • Push event: 263
  • Pull request review comment event: 72
  • Pull request review event: 17
  • Pull request event: 70

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 100
  • Total pull requests: 81
  • Average time to close issues: 11 days
  • Average time to close pull requests: about 13 hours
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.02
  • Merged pull requests: 73
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 100
  • Pull requests: 81
  • Average time to close issues: 11 days
  • Average time to close pull requests: about 13 hours
  • Issue authors: 4
  • Pull request authors: 2
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.02
  • Merged pull requests: 73
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • aioaneia (75)
  • HamedBabaei (22)
  • jd-coderepos (2)
  • nandana (1)
Pull Request Authors
  • HamedBabaei (60)
  • aioaneia (21)
Top Labels
Issue Labels
documentation (75) datasets (73) ontology (73) benchmarks (72) Benchmarking (4) enhancement (4) bug (3) Learner:[step-1]-bring-everything-to-jnb (3) emergency-issue (2) Learner: [step-2]-integrate-to-OntoLearner (2) Ideation (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 401 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 16
  • Total maintainers: 1
pypi.org: ontolearner

OntoLearner: A Modular Python Library for Ontology Learning with LLMs.

  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 401 Last month
Rankings
Dependent packages count: 9.5%
Average: 31.4%
Dependent repos count: 53.3%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/python-publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
docs/requirements.txt pypi
  • myst-parser *
  • sphinx *
  • sphinx-book-theme *
  • sphinx-copybutton *
  • sphinx_autodoc_typehints *
  • sphinx_inline_tabs *
  • sphinx_markdown_tables *
  • sphinxcontrib-mermaid *
pyproject.toml pypi
  • pre-commit * develop
  • ruff * develop
  • setuptools * develop
  • twine * develop
  • wheel * develop
  • matplotlib 3.9.4
  • networkx 3.2.1
  • numpy 1.26.4
  • pandas 2.0.3
  • pathlib 1.0.1
  • pydantic 2.10.5
  • python >=3.10,<4.0.0
  • rdflib 7.1.1
  • seaborn 0.13.2
  • tqdm 4.67.1
requirements.txt pypi
  • matplotlib ==3.9.4
  • networkx ==3.2.1
  • numpy ==1.26.4
  • pandas ==2.0.3
  • pathlib *
  • pydantic ==2.10.5
  • rdflib ==7.1.1
  • seaborn ==0.13.2
  • tqdm ==4.67.1
setup.py pypi
  • matplotlib ==3.9.4
  • networkx ==3.2.1
  • numpy ==1.26.4
  • pandas ==2.0.3
  • pathlib ==1.0.1
  • pydantic ==2.10.5
  • rdflib ==7.1.1
  • seaborn ==0.13.2
  • tqdm ==4.67.1