Skip to main content
A minimal guide to driving GLiNER extraction yourself instead of calling cognify(). You build the task list with get_gliner_tasks(), hand it the exact entity and relation labels you want, and read back a stats object reporting what the model proposed and what survived. A local GLiNER2 model does the extraction and writes the chunk summaries, so no extract_content_graph and no extract_summary calls are made — reach for this when the default labels are not the ones your graph needs, or when you want extraction loss measured rather than assumed.

Before You Start

  • Complete Quickstart to understand basic operations
  • Install the extra: pip install "cognee[gliner]". The first run downloads fastino/gliner2.5-base-v1 (~800 MB) into the Hugging Face cache
  • Configure an embedding provider — extraction and summaries are LLM-free, but add_data_points still embeds what it stores, and the default provider is OpenAI. To keep the text on your machine too, pair this with the local fastembed setup in Recall Without an LLM Key
  • Read Pipelines and Tasks — this guide runs a task list directly instead of calling cognify()
  • No data is required up front — the script ingests its own passage, but it starts with prune_data() and prune_system(), which wipe all existing Cognee data; run it against a setup you can afford to reset
  • The optional search at the end runs only when LLM_API_KEY is set; everything before it does not need one

Code in Action

What Just Happened

Step 1: Ingest the Text

add() stores the passage in the gliner_demo dataset exactly as it would on the LLM path — only the extraction step changes later. The pipeline is run explicitly rather than through cognify(), so it needs a user to run as; get_default_user() is the one cognify() would have used.

Step 2: Declare the Extraction Schema

GLiNER extracts against a closed schema: it only finds the types you name, so the labels here decide what the graph can contain. entity_types accepts either a list of names or a name -> description mapping, and the descriptions help the model tell similar labels apart. get_gliner_tasks() returns the full task list — classify, prepare schema, chunk, extract and summarize, store — and fills stats in as the run progresses.

Step 3: Run the Pipeline Without an LLM

run_custom_pipeline() loads the dataset’s records itself, the same way cognify() does, and runs the GLiNER task list over them. Because every task declares needs_llm=False, the first-run readiness check probes only the embedding provider the pipeline actually uses — a missing LLM key is not an error on this path.

Step 4: Read the Run Stats

GlinerRunStats records what the model proposed against what survived mapping. A relation is dropped when one of its endpoints does not resolve to an extracted entity, so the kept-versus-dropped split measures extraction loss instead of leaving you to guess at it. stats.schemas_by_document additionally reports which schema each document was given and where it came from.

Step 5: Inspect the Stored Graph

Each dataset has its own graph database, so reading it back means entering that dataset’s context first. The prints that follow count nodes by type, dump the TextSummary nodes — the summaries GLiNER wrote, with no extract_summary call behind them — and list the non-structural edges as source --relation--> target.

Advanced Usage

Dropping entity_types and relation_types does not disable the schema — it changes where the schema comes from. get_gliner_tasks() then falls through to the configured OWL ontology (ontology_file_path overrides the ONTOLOGY_FILE_PATH setting), and if there is none, to frozen label banks probed once per document against a sketch of its text.
Read stats.schemas_by_document to see which of the three paths each document took — schema.source names the origin of the labels it was extracted with. This is the one place that answer is visible, so it is worth printing whenever you are not passing labels yourself.
The task list above is what you want when you need the stats object or your own labels. For LLM-free extraction on its own, cognify(extractor="gliner") selects the same list for you — there is nowhere to pass labels on that path, so the schema always resolves itself as described above. See LLM-free extraction with GLiNER for the GRAPH_EXTRACTOR setting and the arguments the extractor rejects.

Recall Without an LLM Key

Run the whole loop — embeddings included — with no API key configured at all.

Custom Tasks and Pipelines

Build and run your own task list, the mechanism this guide borrows.

Ontologies

Where the schema comes from when you do not pass labels yourself.

Embedding Providers

Configure the one provider this pipeline still needs.