- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Have some text data to process
What Custom Tasks and Pipelines Do
- Define custom processing steps using
Taskobjects - Chain multiple operations together in a custom pipeline
- Use LLMs to extract structured data from text
- Insert structured data directly into the knowledge graph
- Control the entire data processing workflow
Code in Action
Step 1: Define Your Pipeline Models
PersonLLM and PeopleLLM describe the structured output the LLM should return. Person is the graph-ready DataPoint, and LightweightData gives the pipeline a simple ingestion object with a stable ID and text field.
Step 2: Create Your Custom Task
Person objects with knows relationships.
Step 3: Build and Run Your Pipeline
Person nodes directly into the graph. The follow-up cognify() call builds the rest of Cognee’s retrieval stack on top of that stored graph data.
If a task raises an exception while processing a data item, the pipeline run yields a
PipelineRunErrored status and then re-raises the original exception to the caller, instead of failing silently. Wrap your pipeline run in try/except so you can handle the propagated error.Step 4: Visualize the Result
knows edges produced by the custom pipeline.
Use Cases
This approach is particularly useful when you need to:- Extract structured data from unstructured text
- Process data through multiple custom steps
- Control the entire data processing workflow
- Combine LLM extraction with programmatic data insertion
- Build complex data processing pipelines
Additional information
Importing an existing graph
Importing an existing graph
If you already have nodes and edges — exported from another graph database, or stored as JSON/CSV — you don’t need the LLM to re-extract them. Map your data to For deterministic re-imports, either map stable source IDs into each DataPoint’s
DataPoint models and store it directly with add_data_points. Because run_custom_pipeline can work with already-built graphs, this recreates your graph deterministically (no LLM extraction step):- Nodes become
DataPointsubclasses, one per entity type. - Edges are expressed as nested
DataPointfields — the field name becomes the relationship label (e.g.employees: list[Person]createsemployeesedges). - Typed or weighted edges use the
Edgemodel: declare the field asSkipValidation[Any]and set values to(Edge(relationship_type="manager", weight=0.9), node)tuples.
id field or configure identity_fields as shown above. Reusing the same node id updates the existing node instead of creating a duplicate. For a complete example that loads nodes and edges from JSON files, see the organizational hierarchy pipeline on GitHub.Additional examples
Additional examples about custom tasks and pipelines are available on our github.Full Example
Latest guide
Latest guide
Legacy guide
Legacy guide
This updated example uses a lightweight ingestion object, a custom extraction task, and a visualization step. In practice, you can create larger pipelines with additional transforms and storage stages.
Custom Data Models
Learn about custom data models
Low-Level LLM
Learn about direct LLM interaction
Core Concepts
Understand knowledge graph fundamentals