CSE Roadmap

Core tier · about 6 hours · 10 parts

Part 2 of 10 · 2 min read

A memory score blends how similar, how recent and how important

Searching memories by meaning alone returns the one that sounds right, not the one that is still true.

Think of searching your own notes app: typing a word brings back every note that uses it, in whatever order the app picked, and nothing in that order tells you which note is still accurate.

In plain words: an embedding turns text into a vector so that similar meanings land close together. Cosine similarity scores how close two vectors are. A retrieval score blends that relevance signal with recency (a decay on age) and importance (set when the memory was written). Similarity alone cannot tell current from outdated, and recency alone cannot tell important from trivial.

A worked example. For the question "When do I like to schedule our call?", two stored facts -- "I prefer meetings at 2pm" (day 19) and "I prefer meetings at 11am" (day 42) -- score an identical 0.70 on similarity alone, because their vectors are nearly the same. Blending in recency separates them: the newer fact scores 0.96 against the older one's 0.88. That's enough to rank the current fact first, but not enough to remove the old one from the top 3 results entirely.

The key lines. From code/mini-recall/store.py:

# from code/mini-recall/store.py
rel = embed.cosine(q, embed.vectorise(it.text, idf))
rec = 0.5 ** (max(0.0, now - it.day) / w.half_life)
if mode == "recency":
    s = rec
elif mode == "similarity":
    s = rel
else:
    s = w.relevance * rel + w.recency * rec + w.importance * it.importance

Read it as: the blended score is a weighted sum of three independently computed numbers: rel, rec and it.importance. None of the three signals can fix what another one gets wrong. Recency can't make a stale fact disappear; it can only outrank it, and that's the whole limitation this module exists to fix.

Embedding, cosine similarity, relevance, recency, importance

An embedding is a vector of numbers computed from text so similar meanings land close together. Cosine similarity is the cosine of the angle between two vectors (1 = same direction, 0 = unrelated). Relevance is that similarity score against the query; recency is a decay on age (0.5^(age / half-life) here, 14-day half-life); importance is a score assigned when the memory is written.

Example: the two meeting-time facts tying at 0.70 relevance is exactly what "relevance can't tell current from outdated" looks like in a real number -- the blend's recency term is what breaks the tie, not the embedding.