Skip to main content

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

Project description

OntoLearner Logo

OntoLearner: A Modular Python Library for Ontology Learning with LLMs

PyPI version PyPI Downloads License: MIT Hugging Face Collection pre-commit Documentation Status Maintenance DOI

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:

pip install ontolearner

Next, verify the installation:

import ontolearner

print(ontolearner.__version__)

🔗 Essential Resources

Resource Info
📚 OntoLearner Documentation Dive into OntoLearner's extensive documentation to explore its modular architecture, including Ontologizers, Learning Tasks, and Learner Models. The documentation provides detailed guides, references, and tutorials to help you get started and make the most of OntoLearner's capabilities.
🤗 Datasets on Hugging Face You can access the curated colloctions of machine-readable ontologies across diverse domains such as agriculture, medicine, social sciences, and more. OntoLearner Benchmarking datasets are optimized for integration into generative AI pipelines, supporting versioning, streaming, and metadata inspection.

🚀 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:

from ontolearner.ontology import Wine

# 1. Initialize an ontologizer from OntoLearner
ontology = Wine()

# 2. Load the ontology automatically from Hugging Face
ontology.load()

# 3. Extract the learning task dataset
data = ontology.extract()

LLM-Based Learning Pipeline:

from ontolearner import ontology, utils, learner

# 1. Load the ontology and extract training data
onto = ontology.Wine()
data = onto.extract()

# 2. Split into train and test sets
train_data, test_data = utils.train_test_split(
    data, test_size=0.2, random_state=42
)

# 3. Initialize a Retrieval-Augmented Generation (RAG) learner
retriever = learner.BERTRetrieverLearner()
llm = learner.AutoLearnerLLM()
prompt = learner.StandardizedPrompting(task="term-typing")

rag_learner = learner.AutoRAGLearner(
    learner_retriever=retriever,
    learner_llm=llm,
    prompting=prompt
)

# 4. Load pretrained components
rag_learner.load(
    retriever_id="sentence-transformers/all-MiniLM-L6-v2",
    llm_id="mistralai/Mistral-7B-Instruct-v0.1"
)

# 5. Fit the model to training data
rag_learner.fit(train_data=train_data, task="term-typing")

# 6. Predict on test data
predicted = rag_learner.predict(test_data, task="term-typing")

⭐ 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:

@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:

@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.0.1},
  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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ontolearner-1.1.0.tar.gz (395.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ontolearner-1.1.0-py3-none-any.whl (91.6 kB view details)

Uploaded Python 3

File details

Details for the file ontolearner-1.1.0.tar.gz.

File metadata

  • Download URL: ontolearner-1.1.0.tar.gz
  • Upload date:
  • Size: 395.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1014-azure

File hashes

Hashes for ontolearner-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bc945ee0a261da19a209ad3135ac8704832f14f23ed89a83d3472e2bda559cb5
MD5 9c8e02d7f94675fe428434147f0d2414
BLAKE2b-256 72c7b5acf785f4495ab1335728f60ad18c7daad91bf6c4f17d5fffe30d2e349a

See more details on using hashes here.

File details

Details for the file ontolearner-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ontolearner-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 91.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1014-azure

File hashes

Hashes for ontolearner-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d6135a8381e3df4c0944bbb98cf69edec27275d9276aa526567b41c403d70e7
MD5 b26c29a55068aa02ebc2a9c7ed838338
BLAKE2b-256 79f45056aa84f321ca410bbe3eb5214842a5e1149f9671296ae070d6b3b4a668

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page