importance_weight. Pass it to remember() when some of what you ingest matters more than the rest — a curated policy document should outrank a passing remark — and you want that preference applied every time the data is ranked, not re-stated in each query.
Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Read Remember for a conceptual overview of ingestion
- Set
LLM_API_KEYin your environment - No data is required up front — the script ingests its own text, but it starts with
cognee.forget(everything=True), which wipes all existing Cognee data; run it against a setup you can afford to reset
Code in Action
What Just Happened
Step 1: Ingest Facts at Different Weights
forget(everything=True) clears the store, so these three facts are all it holds. They land in the same dataset with three different weights: the first omits the argument and keeps the default of 0.5, the second is boosted to 0.7, and the third is dampened to 0.3. The weight is stored on the ingested data record and carried onto everything derived from it — the chunks, their summaries, and the entities extracted from them — so it is a property of the memory rather than of the query. Step 2 shows that propagation on the graph itself.
Step 2: Render the Graph
importance_weight it actually ended up with.
The graph the three remember() calls build, from a real run. One chunk and summary per call, plus the entities extracted from each, meeting only at the shared type nodes. Hover a node to read the importance_weight stored on it.
remember() call stamps its weight — 0.5, 0.7, 0.3 — on the document it ingests, and that value is handed down to the document’s chunk, that chunk’s summary, and every entity extracted from it. The dampened branch is present and connected exactly like the others; only its stored weight differs.
The EntityType nodes are the exception, and the graph is the easiest place to notice it. They are shared rather than per-document, and each ingest rewrites the one it uses, so person and place hold 0.3 — the weight of the last of the three calls to touch them — while date holds 0.7 because only the second call produced it. A type node’s weight therefore reflects ingestion order, not importance; if that matters for your data, weight the documents rather than relying on the types.
Step 3: Recall the Dampened Fact
0.3-weighted fact still answers from it, because nothing else in the dataset is a closer match to the question.
Advanced Usage
How the Weight Enters Ranking
How the Weight Enters Ranking
importance_weight is a float on a 0.0–1.0 scale that defaults to 0.5. Data ingested without the argument is ranked as if it were 0.5, which is also the fallback for any record whose stored weight is missing.Graph retrieval folds the weight into a triplet element’s distance as (2 - importance_weight): 1.0 leaves the distance untouched while 0.0 doubles it, so a higher weight means a shorter effective distance and a better rank. Two further signals can adjust that distance: feedback_weight, which is ignored unless feedback_influence is raised above its default of 0, and a personal preference weight, which applies only to elements the user has rated. importance_weight is the one that always counts — Search walks through the full ranking stage. Hybrid retrieval instead multiplies the ranking score by a factor derived from the weight, and accepts retriever_specific_config={"use_importance_weight": False} to ignore stored weights for a single query — see Search Types.Weighting Existing Data
Weighting Existing Data
The weight is set at ingestion time, so it applies to the records written by that
remember() call. Ingesting the same text again at a new weight is the only way to change it — nothing else rewrites importance_weight.improve() is not that mechanism. It moves a separate feedback_weight on the graph elements that scored answers used, based on how those answers were rated. That weight is a different field and is ignored by graph ranking entirely unless you raise feedback_influence above its default of 0; even then it is blended alongside the importance weight rather than replacing it. improve() never changes the importance_weight you stored.remember()
Full parameter reference for the ingestion call.
Inspecting Hybrid Retrieval Context
See the ranked context a query actually retrieves.
Graph Visualization
More ways to render and seed the graph you just built.