Package com.tnsai.memory.advanced
Class MemoryImportanceScorer
java.lang.Object
com.tnsai.memory.advanced.MemoryImportanceScorer
Computes importance scores for memory entries based on a weighted
combination of recency, frequency, and relevance.
The formula is:
importance = w1 * recency + w2 * frequency + w3 * relevancewhere:
- recency = exponential decay based on time since last access
- frequency = normalized access count
- relevance = externally provided relevance score (e.g., from search)
Weights are normalized to sum to 1.0 at construction time.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a scorer with equal weights (1/3 each).MemoryImportanceScorer(double recencyWeight, double frequencyWeight, double relevanceWeight) Creates a scorer with the given weights. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the frequency weight.doubleReturns the recency weight.doubleReturns the relevance weight.doublescore(MemoryEntry entry) Scores a memory entry without an external relevance signal (relevance=0).doublescore(MemoryEntry entry, double relevance) Scores a memory entry's importance.
-
Constructor Details
-
MemoryImportanceScorer
public MemoryImportanceScorer(double recencyWeight, double frequencyWeight, double relevanceWeight) Creates a scorer with the given weights. Weights are normalized so they sum to 1.0.- Parameters:
recencyWeight- weight for recency componentfrequencyWeight- weight for frequency componentrelevanceWeight- weight for relevance component
-
MemoryImportanceScorer
public MemoryImportanceScorer()Creates a scorer with equal weights (1/3 each).
-
-
Method Details
-
score
Scores a memory entry's importance.- Parameters:
entry- the memory entryrelevance- an external relevance score in [0, 1] (e.g., from vector search)- Returns:
- importance score in [0, 1]
-
score
Scores a memory entry without an external relevance signal (relevance=0).- Parameters:
entry- the memory entry- Returns:
- importance score in [0, 1]
-
recencyWeight
public double recencyWeight()Returns the recency weight. -
frequencyWeight
public double frequencyWeight()Returns the frequency weight. -
relevanceWeight
public double relevanceWeight()Returns the relevance weight.
-