Skip to main content

When to use this

You need SearchType.TRIPLET_COMPLETION with recall() to return results. This search type matches queries against text representations of graph triplets (source β†’ relationship β†’ target). Most users should start with improve(), which runs Cognee’s default enrichment pass. Use this lower-level Memify pipeline directly when you specifically want to build or rebuild triplet embeddings. Before you start:
  • Complete Quickstart to understand basic operations
  • Ensure you have LLM Providers configured
  • Have an existing knowledge graph created with remember()

Code in Action

What Just Happened

  1. Remember β€” builds a knowledge graph with entities and relationships from your text.
  2. get_default_user() β€” retrieves the authenticated user. This pipeline requires a User object with write access to the dataset.
  3. create_triplet_embeddings(user, dataset) β€” iterates over all graph triplets, converts each to a text representation, and indexes them in the vector DB.
  4. Recall with TRIPLET_COMPLETION β€” queries the new Triplet_text collection by semantic similarity.

What Changed in Your Graph

  • The Triplet_text collection is populated in the vector DB. Each entry is a text representation of a graph triplet (source β†’ relationship β†’ target).
  • recall(..., query_type=SearchType.TRIPLET_COMPLETION) queries now return results by matching your query against these triplet embeddings.

Additional Information

  • user (User, required) β€” authenticated user with write access. Obtain via await get_default_user().
  • dataset (str, default: "main_dataset") β€” the dataset whose graph triplets to index.
  • run_in_background (bool, default: False) β€” run asynchronously and return immediately.
  • triplets_batch_size (int, default: 100) β€” how many triplets to index per batch. Lower values use less memory; higher values are faster. The value does not affect coverage: triplets are paginated in a stable order, so a full pass visits each triplet exactly once at any batch size.
Two tasks run in sequence:
  1. get_triplet_datapoints β€” iterates over graph triplets and yields Triplet objects with embeddable text.
  2. index_data_points β€” indexes each triplet in the vector DB under the Triplet_text collection.
get_triplet_datapoints walks the whole graph with an offset loop, calling the graph adapter’s get_triplets_batch(offset, limit) with limit=triplets_batch_size and advancing the offset until a batch comes back short or empty. Every built-in adapter that supports batched reads sorts the triplets on (source node id, target node id, relationship name) before applying the offset, so consecutive calls slice one stable sequence and the loop cannot skip or repeat a triplet. Changing triplets_batch_size changes how the triplets are grouped into batches, not which triplets are visited.
  • Empty results from TRIPLET_COMPLETION β€” ensure the graph has been built with remember() and that create_triplet_embeddings finished without errors.
  • Some triplets missing from Triplet_text on Neo4j or Ladybug β€” on releases before the pagination fix, those two adapters applied SKIP/LIMIT to an unordered result set, so a multi-batch run could skip triplets and leave Triplet_text incomplete even though the pipeline reported success. Upgrade and re-run create_triplet_embeddings to index the missed triplets.
  • Error: no graph data found β€” run cognee.remember(..., dataset_name=...) before calling this pipeline.
  • LLM errors β€” verify that your LLM provider is configured. See LLM Providers.
  • Permission errors β€” the user must have write access to the target dataset. See Permissions.

Improve

Understand the current improvement workflow

Self-Improvement Quickstart

Bridge session memory and enrich a dataset

Recall

Query the enriched graph with v1.0 retrieval