> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Importance Weight

> Boost or dampen stored memories in retrieval ranking with the importance_weight argument to remember()

export const importanceWeightGraph = {
  "nodes": [{
    "id": "bb545a41-49fa-51fe-9a4f-78ed66734fde",
    "name": "This chunk records birthplace and current residences of two people. This chunk is about: - People: Diana, Tom - Places: ",
    "type": "TextSummary",
    "description": "importance_weight 0.5 — inherited from its chunk."
  }, {
    "id": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "name": "Diana and Tom were born and raised in Helsinki. Diana currently resides in Berlin, while Tom never moved.",
    "type": "DocumentChunk",
    "description": "importance_weight 0.5 — inherited from the document its remember() call created."
  }, {
    "id": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "name": "diana",
    "type": "Entity",
    "description": "importance_weight 0.5 — inherited from the chunk it was extracted from. Person mentioned in the text; born and raised in Helsinki and currently resides in Berlin."
  }, {
    "id": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "name": "person",
    "type": "EntityType",
    "description": "importance_weight 0.3 — type nodes are shared, and each ingest rewrites the one it uses, so this holds the weight of the last call to touch it."
  }, {
    "id": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "name": "helsinki",
    "type": "Entity",
    "description": "importance_weight 0.5 — inherited from the chunk it was extracted from. Place where Diana and Tom were born and raised and where Tom currently resides."
  }, {
    "id": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "name": "place",
    "type": "EntityType",
    "description": "importance_weight 0.3 — type nodes are shared, and each ingest rewrites the one it uses, so this holds the weight of the last call to touch it."
  }, {
    "id": "0aa5a634-829a-5222-8568-d7631357800d",
    "name": "berlin",
    "type": "Entity",
    "description": "importance_weight 0.5 — inherited from the chunk it was extracted from. Place where Diana currently resides."
  }, {
    "id": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "name": "tom",
    "type": "Entity",
    "description": "importance_weight 0.5 — inherited from the chunk it was extracted from. Person mentioned in the text; born and raised in Helsinki and has not moved from Helsinki."
  }, {
    "id": "59f06727-d64c-51ec-b516-1de2db56c69e",
    "name": "This chunk is about: - People - Places Facts: - Alice moved to Paris in 2010. - Bob has always lived in New York.",
    "type": "TextSummary",
    "description": "importance_weight 0.7 — inherited from its chunk."
  }, {
    "id": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "name": "Alice moved to Paris in 2010, while Bob has always lived in New York.",
    "type": "DocumentChunk",
    "description": "importance_weight 0.7 — inherited from the document its remember() call created."
  }, {
    "id": "afc75e41-4df3-5db9-907e-dcf55750efec",
    "name": "alice",
    "type": "Entity",
    "description": "importance_weight 0.7 — inherited from the chunk it was extracted from. Person named Alice."
  }, {
    "id": "27d985ea-055a-54fb-bcc4-f29d9d892867",
    "name": "paris",
    "type": "Entity",
    "description": "importance_weight 0.7 — inherited from the chunk it was extracted from. City Paris."
  }, {
    "id": "6dd5cf03-5ad1-5e1a-b215-633dfd34abae",
    "name": "bob",
    "type": "Entity",
    "description": "importance_weight 0.7 — inherited from the chunk it was extracted from. Person named Bob."
  }, {
    "id": "a7852d00-db75-55e2-bd9a-468ada762d39",
    "name": "new york",
    "type": "Entity",
    "description": "importance_weight 0.7 — inherited from the chunk it was extracted from. City New York."
  }, {
    "id": "cb1dc1af-5253-5fa4-877e-246a7629f489",
    "name": "2010",
    "type": "Entity",
    "description": "importance_weight 0.7 — inherited from the chunk it was extracted from. Year 2010."
  }, {
    "id": "b19433ae-558c-5aaf-95ac-6231f2a4be0e",
    "name": "date",
    "type": "EntityType",
    "description": "importance_weight 0.7 — type nodes are shared, and each ingest rewrites the one it uses, so this holds the weight of the last call to touch it."
  }, {
    "id": "bbff7b8d-beec-5206-ac59-eacb632b2207",
    "name": "This chunk is about: - People: Andreas - Places: Venice; Lisbon Facts: - Andreas was born in Venice. - Andreas later set",
    "type": "TextSummary",
    "description": "importance_weight 0.3 — inherited from its chunk."
  }, {
    "id": "88ea00f4-5cc1-5303-a937-be8d61ede760",
    "name": "Andreas was born in Venice, but later settled in Lisbon.",
    "type": "DocumentChunk",
    "description": "importance_weight 0.3 — inherited from the document its remember() call created."
  }, {
    "id": "013d437a-afe1-5f92-b353-c3d10b5fef5d",
    "name": "andreas",
    "type": "Entity",
    "description": "importance_weight 0.3 — inherited from the chunk it was extracted from. Person mentioned in the text."
  }, {
    "id": "25eab197-f492-5a8d-b962-120632d68d14",
    "name": "venice",
    "type": "Entity",
    "description": "importance_weight 0.3 — inherited from the chunk it was extracted from. Place where Andreas was born."
  }, {
    "id": "68e6be9c-ae88-5606-a5f0-7710bdabf28a",
    "name": "lisbon",
    "type": "Entity",
    "description": "importance_weight 0.3 — inherited from the chunk it was extracted from. Place where Andreas later settled."
  }],
  "links": [{
    "source": "bb545a41-49fa-51fe-9a4f-78ed66734fde",
    "target": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "relation": "made_from"
  }, {
    "source": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "target": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "relation": "contains"
  }, {
    "source": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "target": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "relation": "contains"
  }, {
    "source": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "contains"
  }, {
    "source": "f56d877a-ccff-57a7-9063-1472ecc511c1",
    "target": "0aa5a634-829a-5222-8568-d7631357800d",
    "relation": "contains"
  }, {
    "source": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "target": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "relation": "is_a"
  }, {
    "source": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "born_in"
  }, {
    "source": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "raised_in"
  }, {
    "source": "72fdb037-3bdd-5cd4-b6ff-e614e7c67421",
    "target": "0aa5a634-829a-5222-8568-d7631357800d",
    "relation": "resides_in"
  }, {
    "source": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }, {
    "source": "0aa5a634-829a-5222-8568-d7631357800d",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }, {
    "source": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "target": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "relation": "is_a"
  }, {
    "source": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "born_in"
  }, {
    "source": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "raised_in"
  }, {
    "source": "22f6c8d6-f812-5de9-91e0-b7a87f3d1b83",
    "target": "540859f0-8099-5664-97d6-e0b9a74f0104",
    "relation": "resides_in"
  }, {
    "source": "59f06727-d64c-51ec-b516-1de2db56c69e",
    "target": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "relation": "made_from"
  }, {
    "source": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "target": "afc75e41-4df3-5db9-907e-dcf55750efec",
    "relation": "contains"
  }, {
    "source": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "target": "6dd5cf03-5ad1-5e1a-b215-633dfd34abae",
    "relation": "contains"
  }, {
    "source": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "target": "27d985ea-055a-54fb-bcc4-f29d9d892867",
    "relation": "contains"
  }, {
    "source": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "target": "a7852d00-db75-55e2-bd9a-468ada762d39",
    "relation": "contains"
  }, {
    "source": "9b2d8e31-c9d7-572e-adce-88b70155394c",
    "target": "cb1dc1af-5253-5fa4-877e-246a7629f489",
    "relation": "contains"
  }, {
    "source": "afc75e41-4df3-5db9-907e-dcf55750efec",
    "target": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "relation": "is_a"
  }, {
    "source": "afc75e41-4df3-5db9-907e-dcf55750efec",
    "target": "27d985ea-055a-54fb-bcc4-f29d9d892867",
    "relation": "moved_to"
  }, {
    "source": "27d985ea-055a-54fb-bcc4-f29d9d892867",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }, {
    "source": "6dd5cf03-5ad1-5e1a-b215-633dfd34abae",
    "target": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "relation": "is_a"
  }, {
    "source": "6dd5cf03-5ad1-5e1a-b215-633dfd34abae",
    "target": "a7852d00-db75-55e2-bd9a-468ada762d39",
    "relation": "has_always_lived_in"
  }, {
    "source": "a7852d00-db75-55e2-bd9a-468ada762d39",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }, {
    "source": "cb1dc1af-5253-5fa4-877e-246a7629f489",
    "target": "b19433ae-558c-5aaf-95ac-6231f2a4be0e",
    "relation": "is_a"
  }, {
    "source": "bbff7b8d-beec-5206-ac59-eacb632b2207",
    "target": "88ea00f4-5cc1-5303-a937-be8d61ede760",
    "relation": "made_from"
  }, {
    "source": "88ea00f4-5cc1-5303-a937-be8d61ede760",
    "target": "013d437a-afe1-5f92-b353-c3d10b5fef5d",
    "relation": "contains"
  }, {
    "source": "88ea00f4-5cc1-5303-a937-be8d61ede760",
    "target": "25eab197-f492-5a8d-b962-120632d68d14",
    "relation": "contains"
  }, {
    "source": "88ea00f4-5cc1-5303-a937-be8d61ede760",
    "target": "68e6be9c-ae88-5606-a5f0-7710bdabf28a",
    "relation": "contains"
  }, {
    "source": "013d437a-afe1-5f92-b353-c3d10b5fef5d",
    "target": "99a82eec-bb35-5bb5-9ed2-e73fc7a756de",
    "relation": "is_a"
  }, {
    "source": "013d437a-afe1-5f92-b353-c3d10b5fef5d",
    "target": "25eab197-f492-5a8d-b962-120632d68d14",
    "relation": "born_in"
  }, {
    "source": "013d437a-afe1-5f92-b353-c3d10b5fef5d",
    "target": "68e6be9c-ae88-5606-a5f0-7710bdabf28a",
    "relation": "settled_in"
  }, {
    "source": "25eab197-f492-5a8d-b962-120632d68d14",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }, {
    "source": "68e6be9c-ae88-5606-a5f0-7710bdabf28a",
    "target": "5f394058-b2a0-5ba8-8466-ba2a18cfcf4e",
    "relation": "is_a"
  }]
};

export const CogneeGraph = ({data, height = 440, label, fallbackSrc, fallbackAlt}) => {
  const D3_SRC = "https://d3js.org/d3.v7.min.js";
  const COLORS = {
    Entity: "#6510F4",
    EntityType: "#A78BFA",
    DocumentChunk: "#78716C",
    TextSummary: "#2563EB",
    TextDocument: "#A8A29E",
    Company: "#6510F4",
    Department: "#A550FF",
    Person: "#0EA5E9",
    CompanyType: "#94A3B8",
    _default: "#94A3B8"
  };
  const loadD3 = () => {
    if (typeof window === "undefined") return Promise.reject(new Error("no window"));
    if (window.d3 && window.d3.forceSimulation) return Promise.resolve(window.d3);
    if (window.__cogneeD3Promise) return window.__cogneeD3Promise;
    window.__cogneeD3Promise = new Promise((resolve, reject) => {
      const script = document.createElement("script");
      script.src = D3_SRC;
      script.onload = () => window.d3 && window.d3.forceSimulation ? resolve(window.d3) : reject(new Error("d3 loaded without the force module"));
      script.onerror = () => reject(new Error("could not load d3 from " + D3_SRC));
      document.head.appendChild(script);
    });
    return window.__cogneeD3Promise;
  };
  const isDark = () => document.documentElement.classList.contains("dark");
  const colorForNode = d => d.color || COLORS[d.type] || COLORS._default;
  const labelFor = d => {
    const name = d.name || "";
    return name.length > 30 ? name.slice(0, 29) + "…" : name;
  };
  const drawGraph = (host, data, d3, height, label) => {
    const width = host.clientWidth || 680;
    const nodes = data.nodes.map(n => Object.assign({}, n));
    const links = data.links.map(l => Object.assign({}, l));
    const degree = {};
    links.forEach(l => {
      degree[l.source] = (degree[l.source] || 0) + 1;
      degree[l.target] = (degree[l.target] || 0) + 1;
    });
    host.textContent = "";
    const svg = d3.select(host).append("svg").attr("width", "100%").attr("height", height).attr("viewBox", [0, 0, width, height]).attr("role", "img").attr("aria-label", label || "Knowledge graph").style("display", "block").style("max-width", "100%").style("cursor", "grab");
    const root = svg.append("g");
    const zoom = d3.zoom().scaleExtent([0.3, 6]).on("zoom", event => root.attr("transform", event.transform));
    svg.call(zoom);
    const link = root.append("g").attr("stroke-linecap", "round").selectAll("line").data(links).join("line").attr("stroke", () => isDark() ? "#4b5563" : "#cbd5e1").attr("stroke-width", 1.2);
    const node = root.append("g").selectAll("g").data(nodes).join("g").style("cursor", "pointer");
    node.append("circle").attr("r", d => 6 + Math.min(degree[d.id] || 0, 6)).attr("fill", d => colorForNode(d)).attr("stroke", () => isDark() ? "#111827" : "#ffffff").attr("stroke-width", 1.5);
    node.append("title").text(d => d.name + " — " + d.type + (d.description ? "\n" + d.description : ""));
    node.append("text").text(d => labelFor(d)).attr("x", d => 9 + Math.min(degree[d.id] || 0, 6)).attr("y", 4).attr("font-size", 11).attr("font-family", "system-ui, -apple-system, sans-serif").attr("fill", () => isDark() ? "#e5e7eb" : "#374151").attr("paint-order", "stroke").attr("stroke", () => isDark() ? "#0b0b0d" : "#ffffff").attr("stroke-width", 3);
    const neighbors = {};
    links.forEach(l => {
      (neighbors[l.source] = neighbors[l.source] || ({}))[l.target] = true;
      (neighbors[l.target] = neighbors[l.target] || ({}))[l.source] = true;
    });
    const hasDetails = nodes.some(n => n.description) || links.some(l => l.edge_text);
    const details = hasDetails ? document.createElement("div") : null;
    const DETAILS_HINT = "Hover a node to read its description and the text stored on its edges.";
    const muted = () => isDark() ? "#9ca3af" : "#6b7280";
    const strong = () => isDark() ? "#e5e7eb" : "#374151";
    const showDetails = d => {
      if (!details) return;
      details.textContent = "";
      const head = document.createElement("div");
      head.style.cssText = "font-weight:600;color:" + strong();
      head.textContent = d.name + " · " + d.type;
      details.appendChild(head);
      if (d.description) {
        const desc = document.createElement("div");
        desc.style.cssText = "margin-top:4px;color:" + strong();
        desc.textContent = d.description;
        details.appendChild(desc);
      }
      const incident = links.filter(l => l.source.id === d.id || l.target.id === d.id);
      if (incident.length) {
        const list = document.createElement("ul");
        list.style.cssText = "margin:6px 0 0;padding-left:18px;color:" + muted();
        incident.forEach(l => {
          const item = document.createElement("li");
          item.style.cssText = "margin:2px 0";
          const rel = document.createElement("code");
          rel.style.cssText = "font-size:11px";
          rel.textContent = l.source.name + " —" + (l.relation || "") + "→ " + l.target.name;
          item.appendChild(rel);
          if (l.edge_text) {
            item.appendChild(document.createTextNode(" " + l.edge_text));
          }
          list.appendChild(item);
        });
        details.appendChild(list);
      }
    };
    const resetDetails = () => {
      if (!details) return;
      details.textContent = DETAILS_HINT;
      details.style.color = muted();
    };
    node.on("mouseenter", (event, d) => {
      node.style("opacity", o => o.id === d.id || neighbors[d.id] && neighbors[d.id][o.id] ? 1 : 0.15);
      link.style("opacity", l => l.source.id === d.id || l.target.id === d.id ? 1 : 0.08);
      showDetails(d);
    }).on("mouseleave", () => {
      node.style("opacity", 1);
      link.style("opacity", 1);
      resetDetails();
    });
    const draw = () => {
      link.attr("x1", d => d.source.x).attr("y1", d => d.source.y).attr("x2", d => d.target.x).attr("y2", d => d.target.y);
      node.attr("transform", d => "translate(" + d.x + "," + d.y + ")");
    };
    const setLabelScale = counter => {
      node.selectAll("text").attr("font-size", 11 * counter).attr("stroke-width", 3 * counter).attr("y", 4 * counter).attr("x", d => (9 + Math.min(degree[d.id] || 0, 6)) * counter);
    };
    const scaleFor = box => {
      const pad = 14;
      return Math.min((width - pad * 2) / box.width, (height - pad * 2) / box.height, 1.4);
    };
    const fit = () => {
      let box = root.node().getBBox();
      if (!(box.width > 0) || !(box.height > 0)) return;
      let scale = scaleFor(box);
      for (let pass = 0; pass < 3; pass++) {
        setLabelScale(Math.min(Math.max(1 / scale, 1), 1.9));
        box = root.node().getBBox();
        scale = scaleFor(box);
      }
      const tx = (width - scale * (box.x * 2 + box.width)) / 2;
      const ty = (height - scale * (box.y * 2 + box.height)) / 2;
      svg.call(zoom.transform, d3.zoomIdentity.translate(tx, ty).scale(scale));
    };
    const simulation = d3.forceSimulation(nodes).force("link", d3.forceLink(links).id(d => d.id).distance(70).strength(0.6)).force("charge", d3.forceManyBody().strength(-320)).force("center", d3.forceCenter(width / 2, height / 2)).force("collide", d3.forceCollide(34));
    simulation.stop();
    for (let i = 0; i < 320; i++) simulation.tick();
    draw();
    fit();
    simulation.on("tick", draw);
    node.call(d3.drag().on("start", (event, d) => {
      if (!event.active) simulation.alphaTarget(0.3).restart();
      d.fx = d.x;
      d.fy = d.y;
    }).on("drag", (event, d) => {
      d.fx = event.x;
      d.fy = event.y;
    }).on("end", (event, d) => {
      if (!event.active) simulation.alphaTarget(0);
      d.fx = null;
      d.fy = null;
    }));
    const counts = {};
    const swatch = {};
    nodes.forEach(n => {
      counts[n.type] = (counts[n.type] || 0) + 1;
      if (!swatch[n.type]) swatch[n.type] = colorForNode(n);
    });
    const legend = document.createElement("div");
    legend.style.cssText = "display:flex;flex-wrap:wrap;gap:12px;padding:8px 2px 0;font-size:12px;" + "font-family:system-ui,-apple-system,sans-serif;color:" + (isDark() ? "#9ca3af" : "#6b7280");
    Object.keys(counts).sort().forEach(type => {
      const item = document.createElement("span");
      item.style.cssText = "display:inline-flex;align-items:center;gap:5px";
      const dot = document.createElement("span");
      dot.style.cssText = "width:9px;height:9px;border-radius:50%;background:" + swatch[type];
      item.appendChild(dot);
      item.appendChild(document.createTextNode(type + " (" + counts[type] + ")"));
      legend.appendChild(item);
    });
    host.appendChild(legend);
    if (details) {
      details.style.cssText = "margin-top:8px;padding:8px 10px;border-radius:6px;font-size:12px;" + "line-height:1.45;font-family:system-ui,-apple-system,sans-serif;" + "min-height:3.2em;background:" + (isDark() ? "#111827" : "#f8fafc");
      resetDetails();
      host.appendChild(details);
    }
    return () => simulation.stop();
  };
  const hostRef = useRef(null);
  const fallbackRef = useRef(null);
  useEffect(() => {
    let cancelled = false;
    let teardown = null;
    let themeObserver = null;
    let sizeObserver = null;
    const hideFallback = () => {
      if (fallbackRef.current) fallbackRef.current.style.display = "none";
    };
    const whenVisible = host => host.offsetParent !== null ? Promise.resolve() : new Promise(resolve => {
      const done = () => {
        if (sizeObserver) sizeObserver.disconnect();
        resolve();
      };
      sizeObserver = new ResizeObserver(() => {
        if (host.offsetParent !== null) done();
      });
      sizeObserver.observe(host);
      setTimeout(done, 10000);
    });
    loadD3().then(d3 => hostRef.current ? whenVisible(hostRef.current).then(() => d3) : d3).then(d3 => {
      if (cancelled || !hostRef.current) return;
      teardown = drawGraph(hostRef.current, data, d3, height, label);
      hideFallback();
      let wasDark = isDark();
      themeObserver = new MutationObserver(() => {
        if (isDark() === wasDark || cancelled || !hostRef.current) return;
        wasDark = isDark();
        if (teardown) teardown();
        teardown = drawGraph(hostRef.current, data, d3, height, label);
      });
      themeObserver.observe(document.documentElement, {
        attributes: true,
        attributeFilter: ["class"]
      });
    }).catch(err => {
      console.warn("[CogneeGraph] falling back to the static image:", err.message);
    });
    return () => {
      cancelled = true;
      if (teardown) teardown();
      if (themeObserver) themeObserver.disconnect();
      if (sizeObserver) sizeObserver.disconnect();
    };
  }, [data, height, label]);
  return <div style={{
    position: "relative",
    minHeight: height
  }} data-cognee-graph="">
      <div ref={hostRef} style={{
    minHeight: height
  }} />
      {fallbackSrc ? <img ref={fallbackRef} src={fallbackSrc} alt={fallbackAlt || label || "Knowledge graph"} style={{
    position: "absolute",
    top: 0,
    left: 0,
    width: "100%",
    height: height,
    objectFit: "contain"
  }} /> : null}
    </div>;
};

A minimal guide to biasing retrieval with `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](/getting-started/quickstart) to understand basic operations
* Ensure you have [LLM Providers](/setup-configuration/llm-providers) configured
* Read [Remember](/core-concepts/main-operations/remember) for a conceptual overview of ingestion
* Set `LLM_API_KEY` in 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

```python theme={null}
import asyncio
import os

import cognee
from cognee import visualize_graph


async def main():
    await cognee.forget(everything=True)

    await cognee.remember(
        "Diana and Tom were born and raised in Helsinki. Diana currently resides in Berlin, while Tom never moved.",
        dataset_name="importance_demo",
        self_improvement=False,
    )
    await cognee.remember(
        "Alice moved to Paris in 2010, while Bob has always lived in New York.",
        dataset_name="importance_demo",
        importance_weight=0.7,
        self_improvement=False,
    )
    await cognee.remember(
        "Andreas was born in Venice, but later settled in Lisbon.",
        dataset_name="importance_demo",
        importance_weight=0.3,
        self_improvement=False,
    )

    visualize_graph_path = os.path.join(
        os.path.dirname(__file__), ".artifacts", "importance_weight.html"
    )
    await visualize_graph(visualize_graph_path)

    result = await cognee.recall(
        "In which cities did Andreas live?",
        datasets=["importance_demo"],
    )
    print(result)


if __name__ == "__main__":
    asyncio.run(main())
```

## What Just Happened

### Step 1: Ingest Facts at Different Weights

```python theme={null}
await cognee.forget(everything=True)

await cognee.remember(
    "Diana and Tom were born and raised in Helsinki. Diana currently resides in Berlin, while Tom never moved.",
    dataset_name="importance_demo",
    self_improvement=False,
)
await cognee.remember(
    "Alice moved to Paris in 2010, while Bob has always lived in New York.",
    dataset_name="importance_demo",
    importance_weight=0.7,
    self_improvement=False,
)
await cognee.remember(
    "Andreas was born in Venice, but later settled in Lisbon.",
    dataset_name="importance_demo",
    importance_weight=0.3,
    self_improvement=False,
)
```

`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

```python theme={null}
visualize_graph_path = os.path.join(
    os.path.dirname(__file__), ".artifacts", "importance_weight.html"
)
await visualize_graph(visualize_graph_path)
```

The three ingests produce one graph, and weighting does not change its shape — only how its elements rank during retrieval. Weight is stored, not drawn, so the graph below carries it in the hover text: every node is from a real run of this script, and hovering one shows the `importance_weight` it actually ended up with.

<Frame caption="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.">
  <CogneeGraph data={importanceWeightGraph} height={520} label="Knowledge graph from the importance weight script: three weighted chunks, each with its summary and extracted entities" fallbackSrc="/images/examples/importance-weight-graph.png" fallbackAlt="Force-directed graph of three chunk-and-summary clusters with their extracted entities, joined only at the shared person, place and date type nodes." />
</Frame>

Reading the weights off the graph shows how far one argument reaches. Each `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

```python theme={null}
result = await cognee.recall(
    "In which cities did Andreas live?",
    datasets=["importance_demo"],
)
print(result)
```

A low weight biases ranking; it does not hide data. Asking directly about the `0.3`-weighted fact still answers from it, because nothing else in the dataset is a closer match to the question.

## Advanced Usage

<Accordion title="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](/core-concepts/main-operations/legacy-operations/search#retrievers) 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](/python-api/search-type).
</Accordion>

<Accordion title="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()](/core-concepts/main-operations/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.
</Accordion>

<Columns cols={3}>
  <Card title="remember()" icon="brain" href="/python-api/remember">
    Full parameter reference for the ingestion call.
  </Card>

  <Card title="Inspecting Hybrid Retrieval Context" icon="layers" href="/guides/hybrid-retrieval-recall">
    See the ranked context a query actually retrieves.
  </Card>

  <Card title="Graph Visualization" icon="network" href="/guides/graph-visualization">
    More ways to render and seed the graph you just built.
  </Card>
</Columns>
