Extract a knowledge graph with LLM from texts and perform QA over the resulted KG
Project description
Wikontic
Build ontology-aware, Wikidata-aligned knowledge graphs from raw text using LLMs
🚀 Overview
Knowledge Graphs (KGs) provide structured, verifiable representations of knowledge, enabling fact grounding and empowering large language models (LLMs) with up-to-date, real-world information. However, creating high-quality KGs from open-domain text is challenging due to issues like redundancy, inconsistency, and lack of alignment with formal ontologies.
Wikontic is a multi-stage pipeline for constructing ontology-aligned KGs from unstructured text using LLMs and Wikidata. It extracts candidate triples from raw text, then refines them through ontology-based typing, schema validation, and entity deduplication—resulting in compact, semantically coherent graphs.
📁 Repository Structure
-
preprocessing/constraint-preprocessing.ipynb
Jupyter notebook for collecting constraint rules from Wikidata. -
utils/
Utilities for LLM-based triple extraction and alignment with Wikidata ontology rules. -
utils/openai_utils.py
LLMTripletExtractorclass for LLM-based triple extraction.
To use ontology:
-
utils/ontology_mappings/
JSON files containing ontology mappings from Wikidata. -
utils/structured_inference_with_db.pyStructuredInferenceWithDBclass: triple extraction and qa functions
-
utils/structured_aligner.pyAlignerclass: ontology alignment and entity name refinement
Not to use ontology:
-
utils/inference_with_db.pyInferenceWithDBclass: triple extraction and qa functions
-
utils/dynamic_aligner.pyAlignerclass: entity and relation name refinement
Evaluation:
inference_and_eval- Scripts for building KGs for MuSiQue and HotPot datasets and evaluation of QA performance
analysis- Notebooks with downstream analysis of the resulted KG
Use Wikontic as a service:
-
pages/andWikontic.py
Code for the web service for knowledge graph extraction and visualization. -
Dockerfile
For building a containerized web service.
🏁 Getting Started
-
Set up the ontology and KG databases:
./setup_db.sh -
Launch the web service:
streamlit run Wikontic.py
Enjoy building knowledge graphs with Wikontic!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wikontic-0.0.1.tar.gz.
File metadata
- Download URL: wikontic-0.0.1.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f699105d79ec42fc42078f49b432c573ca1d0b969ff60451b6986ca902e29f
|
|
| MD5 |
ed970acbe174c6f8a4dd472b730eeaae
|
|
| BLAKE2b-256 |
c738181ec1f30cd9ac27ed292ade77b5965da535dfe980f89060b5894f04d250
|
File details
Details for the file wikontic-0.0.1-py3-none-any.whl.
File metadata
- Download URL: wikontic-0.0.1-py3-none-any.whl
- Upload date:
- Size: 68.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d89b954b3a12390790ad3f065796ef17c2a826d3fdb921c75db0cc45a75cb957
|
|
| MD5 |
d3a30fb9fbf30f4a54063dc2e0535897
|
|
| BLAKE2b-256 |
28b633feaf8f65937cbef186af0d54b865a39d816519d3c9985b450065f2e246
|