remember() so the data and ontology config are processed together in one call.
Before you start:
- Complete Quickstart to understand basic operations
- Read Ontologies to understand the concepts
- Ensure you have LLM Providers configured
- Have an OWL ontology file (
.owl) in RDF/XML format - Have some text or files relevant to the ontology’s domain
What Ontology Support Does
- Grounds entities and relations to your OWL ontology (classes, individuals, properties)
- Validates types via ontology domains/ranges and class hierarchy
- Improves graph completion answers for domain-specific queries
Step 1: Prepare an Ontology File
Start from a simple OWL file. Minimal ingredients:- Classes (e.g.,
TechnologyCompany,Car) - Individuals (e.g.,
Apple,Audi) - Object properties with domain/range (e.g.,
produceswithdomain=CarManufacturer,range=Car)
examples/guides/ontology_input_example/basic_ontology.owl(GitHub)
This example uses a simple ontology for demonstration. In practice, you can work with larger, more complex ontologies - the same approach works regardless of ontology size or complexity.
Step 2: Prepare Your Data
Add either raw text or a directory. Keep it relevant to your ontology.This simple example uses a list of strings for demonstration. In practice, you can add multiple documents, files, or entire datasets - the ontology processing works the same way across all your data.
Step 3: Remember Your Data with the Ontology Config
Create theconfig that contains the ontology information, then pass it directly to remember().
If omitted, Cognee builds memory without ontology grounding. With an ontology config, Cognee aligns nodes to classes and individuals while processing the remembered data.
Hot Reload and File Updates
Ontology files are parsed once at initialization — whenRDFLibOntologyResolver is constructed, it reads and parses the file with RDFLib and caches the result in memory. There is no automatic file system monitoring, so changes to the .owl file on disk are not picked up while a session or server is running.
Full Example
Latest guide
Latest guide
Legacy guide
Legacy guide
- Basic ontology demo script can be found on the following link
- Advanced ontology demo script can be found on the following link
Core Concepts
Understand ontology fundamentals
API Reference
Explore ontology API endpoints