Skip to Content
How-to GuidesOptimizationDescriptive Metrics

Descriptive Metrics for Graph Validation

The descriptive metrics functionality in Cognee provides key insights into the correctness and structure of the generated knowledge graph. These metrics help ensure the integrity of the graph, detect inconsistencies, and evaluate the efficiency of the Cognee pipeline.

Here’s how to generate descriptive metrics in Cognee:

Step 1: Prepare your documents

 

For this example, let’s use a short text.

text = """ Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval. """

Step 2: Prune, Add, Cognify!

 

Before processing new data, clear any previously stored information.

await cognee.prune.prune_data() await cognee.prune.prune_system(metadata=True)

Add the documents (in this case, a single string) to Cognee.

await cognee.add(text)

Cognify! (Knowledge graph generation step)

  • This step extracts insights, generates summaries, and creates connections.
  • During this process, descriptive metrics are calculated in the background.
pipeline_run = await cognee.cognify()

Step 3: Calculate and save descriptive metrics

 

This step saves descriptive metrics to the database. Resource-intensive calculations can be turned off using the include_optional parameter.

await cognee.get_pipeline_run_metrics(pipeline_run, include_optional=True)

Step 4: Retrieve descriptive metrics from the database

  • Open PG Admin (or your database management tool) and refresh the database.
Refresh database
  • Find the graph_metrics table and retrieve the computed metrics.
Metrics in pgadmin

Note: postgres and pgvector needs to be set in the env variables

For interpreting graph metrics, see our Descriptive Metrics reference.

Join the Conversation!

Join our community now to connect with professionals, share insights, and get your questions answered!