Ontology concept
Cognee optionally uses rdf/xml ontologies to ground the knowledge base with general information about individuals and classes. Cognee ontology support feature connects your data to external graph-like ground truth. The ontology itself needs to be (manually) defined and make it available to the system at cognification time using the file path. You can check out our blog on the topic.
In order to add your own (external) ontologies you can provide it as a parameter to the main cognify pipeline in the following way:
pipeline_run = await cognee.cognify(ontology_file_path='YOUR_ONTOLOGY_PATH')
Cognify Parameters:
-
datasets: Union[str, list[str]] = None
: A string or list of dataset names to be processed. -
user: User = None
: The user requesting the processing. If not provided, the default user is retrieved. -
ontology_file_path: Optional = None
: File path of the rdf/xml ontology file. If not provided, the default ontology is an empty ontology
Ontology matching algorithm logic
Entity Extraction:
The main Cognee pipeline first extracts entities, their types, and connections from the textual input.
Subgraph Matching:
The system compares and matches nodes from the ontology to the extracted entities or entity types based on node similarity.
Mapping Entities and Classes:
Entities are linked to specific individuals in the ontology. Entity types are associated with corresponding ontology classes.
Knowledge Graph Enrichment:
Once a match is identified, Cognee retrieves the relevant subgraph from the ontology and merges its nodes and edges into the knowledge graph. This process enhances the knowledge graph with a semantically rich, ontology-grounded structure.
Checkout our Use Ontologies Tutorial for a detailed walkthrough where we provide you with an example ontology file and script you can run yourself.
Join the Conversation!
Have questions? Join our community now to connect with professionals, share insights, and get your questions answered!