ontolearner
OntoLearner: A Modular Python Library for Ontology Learning with LLMs https://pypi.org/project/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
Repository
OntoLearner: A Modular Python Library for Ontology Learning with LLMs https://pypi.org/project/OntoLearner/
Basic Info
- Host: GitHub
- Owner: sciknoworg
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://ontolearner.readthedocs.io
- Size: 4.45 MB
Statistics
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 9
- Releases: 0
Topics
Metadata Files
README.md
OntoLearner: A Modular Python Library for Ontology Learning with LLMs
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
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 and is licensed under
.
Owner
- Name: SciKnowOrg
- Login: sciknoworg
- Kind: organization
- Email: sciknoworg@gmail.com
- Location: Germany
- Repositories: 1
- Profile: https://github.com/sciknoworg
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
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.
- Homepage: https://ontolearner.readthedocs.io/
- Documentation: https://ontolearner.readthedocs.io/
- License: MIT
-
Latest release: 1.4.2
published 4 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/setup-python v4 composite
- myst-parser *
- sphinx *
- sphinx-book-theme *
- sphinx-copybutton *
- sphinx_autodoc_typehints *
- sphinx_inline_tabs *
- sphinx_markdown_tables *
- sphinxcontrib-mermaid *
- 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
- 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
- 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