Class MemoryImportanceScorer

java.lang.Object
com.tnsai.memory.advanced.MemoryImportanceScorer

public final class MemoryImportanceScorer extends Object
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 * relevance
 
where:
  • 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 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 component
      frequencyWeight - weight for frequency component
      relevanceWeight - weight for relevance component
    • MemoryImportanceScorer

      public MemoryImportanceScorer()
      Creates a scorer with equal weights (1/3 each).
  • Method Details

    • score

      public double score(MemoryEntry entry, double relevance)
      Scores a memory entry's importance.
      Parameters:
      entry - the memory entry
      relevance - an external relevance score in [0, 1] (e.g., from vector search)
      Returns:
      importance score in [0, 1]
    • score

      public double score(MemoryEntry entry)
      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.