Skip to main content

What it does

Supplies an ontology (RDF/OWL, Turtle, or JSON-LD) to cognify so extracted entities are matched and grounded against a known vocabulary. The OntologyResolver loads the file and matches extracted entity names/types to ontology terms during knowledge-graph extraction.

When to use it

  • You have a controlled vocabulary / taxonomy and want extraction to align with it (consistent entity types, canonical names).
  • You want to constrain or normalize the messy free-form output of an LLM.

CLI

cognee-cli cognify exposes the ontology file directly:
cognee-cli cognify -d my_dataset --ontology-file ./ontologies/domain.owl
The flag is --ontology-file <path> (crates/cli/src/cli.rs, CognifyArgs).

Configuration (env / config keys)

You can also set the ontology globally instead of per-invocation:
Env varConfig keyDefault
ONTOLOGY_FILE_PATHontology_file_path(empty)
ONTOLOGY_RESOLVERontology_resolverrdflib
ONTOLOGY_MATCHING_STRATEGYontology_matching_strategyfuzzy
export ONTOLOGY_FILE_PATH=./ontologies/domain.owl
cognee-cli cognify -d my_dataset
Note: ontology_resolver and ontology_matching_strategy are stored for parity but the active path currently uses the RDF/JSON-LD/Turtle resolver with a fuzzy matching strategy whenever an ontology file is set. See configuration.md for the full surface and crates/lib/src/config.rs for the field definitions and set_ontology_* setters.

Supported formats

RDF/OWL, Turtle, and JSON-LD, parsed via the sophia family of crates. See crates/ontology/ for the resolver implementations and the test fixtures under crates/ontology/tests/fixtures/.

Pointers