# Managing Infinite Memory: Neuro-Inspired Selective Forgetting in Graph RAG

### Executive Summary

Standard Vector Retrieval-Augmented Generation (RAG) suffers from two main issues in long-horizon operations: **context degradation** (where irrelevant historical chunks pollute model context) and **quadratic token expense**.

Graph-structured memory offers superior multi-hop reasoning over unstructured vector databases, but without continuous maintenance, knowledge graphs experience exponential node growth. This article introduces the **Neuro-Inspired Selective Forgetting Engine**, a dynamic pruning framework that bounds context sizes while preserving vital relational memory.

![](https://cdn.hashnode.com/uploads/covers/6a157ef2da253d50d4a02fc4/bc318a96-01ba-47b7-be8c-4babb3cbaa92.png align="center")

The Selective Forgetting Mathematical Model To decide which knowledge nodes remain in high-priority working context, each node v in the graph receives a dynamic retention score S(v):

S(v) = (w1 \* R(v)) + (w2 \* F(v)) + (w3 \* C(v)) - (w4 \* A(v))

Where:

R(v) \[Recency\]: Exponential decay calculated from the time of last retrieval:

R(v) = exp(-lambda \* delta\_t)

F(v) \[Frequency\]: Total retrieval count over a rolling operational window.

C(v) \[Degree Centrality\]: The graph-level importance measure of node v based on its connected edges.

A(v) \[Age\]: Absolute elapsed time since the node was created.

w1, w2, w3, w4: Hyperparameters tuned based on workload characteristics.

### Memory Lifecycle and Pruning Flow

Nodes whose retention score **S(v)** drops below the dynamic threshold undergo a two-tier offloading process:

![](https://cdn.hashnode.com/uploads/covers/6a157ef2da253d50d4a02fc4/739ca62c-3edd-4c08-9a95-a65fb198d02c.png align="center")

By periodically compressing medium-tier nodes into generalized abstract nodes and archiving cold nodes, the active knowledge graph stays small. This guarantees fast multi-hop retrieval times while maintaining strict control over token usage.
