What is the improve operation
The.improve operation enriches an existing Cognee graph after data has already been ingested.
- Graph enrichment: by default,
improve()runs Cognee’s built-in enrichment pass on an existing dataset, adding derived retrieval structures that make later recall work better. - Session bridging: with
session_ids, it moves useful session memory into the permanent graph. - Feedback-aware: it can raise or lower the importance of graph elements based on feedback attached to session answers that used those elements during retrieval.
- Sync back to sessions: after enrichment, it can write new graph relationships back into session cache for faster future session recall.
Where improve fits
- Use
improve()after Remember when you want to enrich an existing graph further. - Use it at the end of a chat or agent session to bridge short-term session memory into permanent memory.
- Use it when you want custom extraction or enrichment tasks.
- Use it instead of re-ingesting everything when the graph already exists and you want additive enrichment.
What happens under the hood
Without session IDs
- Run graph enrichment
improve()runs an enrichment pass on the target dataset.- By default, this extracts and indexes triplet datapoints when triplet embeddings are enabled.
- For coding-rule retrieval, pass explicit coding-rule extraction and enrichment tasks.
With session IDs
Whensession_ids is provided, Cognee runs four stages:
-
Apply feedback weights
- Session feedback updates
feedback_weighton graph nodes and edges that were used during retrieval. - In practice, this means highly rated answers can make their source graph elements more influential later, while poorly rated answers can reduce their influence.
- Session feedback updates
-
Persist session Q&A
- Question-and-answer content from the session is cognified into the permanent graph.
- Persisted session content is tagged under the
user_sessions_from_cachenode set.
-
Run enrichment
- The dataset goes through the normal enrichment pass.
-
Sync graph back to sessions
- Newly enriched graph relationships are copied back into the session cache as human-readable context.
After improve finishes
- Without session IDs: the target dataset has gone through the enrichment pass and is ready for better downstream retrieval.
- With session IDs: session feedback and Q&A can be persisted into the permanent graph, enrichment runs, and new graph context may be synced back into those sessions.
Examples and details
What graph enrichment means
What graph enrichment means
In the context of
improve(), graph enrichment means adding new derived retrieval structures or knowledge on top of an already-built graph instead of re-ingesting the original source data from scratch.By default, that usually means:- extracting and indexing triplet datapoints when triplet embeddings are enabled
- improving how the graph can be searched later
- optionally adding extra derived structures through custom tasks
improve() is not the stage that first creates the graph. Instead, it makes an existing graph more useful for future retrieval.What feedback weights mean
What feedback weights mean
Feedback weights are stored importance signals attached to graph elements that were used during retrieval.
- When a session answer has feedback and Cognee knows which graph nodes or edges helped produce that answer,
improve()can update those elements’feedback_weight. - Positive feedback can make those elements more influential in future ranking.
- Negative feedback can make them less influential.
- If no retrieval trace exists for the session, or if no feedback was captured, this stage may have little or nothing to update.
How custom improvement tasks work
How custom improvement tasks work
improve() supports power-user overrides for custom extraction and enrichment tasks.extraction_taskslets you define what intermediate subgraph or source material should be prepared.enrichment_taskslets you define what new derived structures should be added to the graph.- This is how you move beyond the default enrichment pass and create domain-specific memory behavior.
What improve produces
What improve produces
- Enriched graph structures on the target dataset
- Triplet-embedding style retrieval artifacts (when triplet embeddings are enabled)
- Optional persistence of session Q&A into the permanent graph
- Optional feedback-based weighting updates on graph elements used during retrieval
- Optional sync of newly enriched graph context back into session cache
What improve needs before it can help
What improve needs before it can help
- A target dataset must already exist.
- That dataset should already contain graph memory, usually created by Remember.
- Session bridging only applies when you pass
session_ids. - Feedback-based weighting only helps when those sessions contain feedback and retrieval traces.
improve() on a dataset with no existing graph content, or pass sessions that have no useful cached interactions, the operation may run successfully but add little new value.Bridge session memory into the graph
Bridge session memory into the graph
- This applies feedback weights from those sessions.
- It persists the session Q&A into the permanent graph.
- It enriches the graph and syncs new context back into the sessions.
Parameters
Parameters
- Basic Parameters
- Advanced Parameters
| Option | What it does |
|---|---|
dataset | The dataset name or UUID to improve. Defaults to main_dataset. |
session_ids | Bridges those sessions into the permanent graph and syncs graph context back. |
run_in_background | Runs the improvement pipeline asynchronously. |
node_name | Restricts improvement to specific named entities or node sets. |
feedback_alpha | Controls how strongly session feedback changes graph weights. |
Under the hood — legacy operations
Under the hood — legacy operations
improve() runs Memify under the hood for its enrichment pass.Use legacy Memify directly when you need fine-grained control over extraction and enrichment tasks — for example, to supply custom task lists or target specific pipeline stages. Note that remember(..., self_improvement=True) already calls improve() for you after permanent ingestion.Remember
Ingest and build memory in one call
Recall
Query the improved graph and session memory