Long-Term Memory — Retrieval and Forgetting
After a year, Tripmate holds hundreds of notes about Asha's trips. When she asks, "What was that quiet hotel near the station in Udaipur?", it cannot paste all of them into the context. It must find the few that matter — and, over time, let go of the ones that no longer do.
The rule
Store by meaning, retrieve the few that matter, and let stale memories fade.
Embeddings make searching by meaning possible. An embedding model turns a piece of text into a long list of numbers — a vector — so that texts with similar meanings get vectors that are close together. "Quiet hotel near Udaipur station" lands near "calm guesthouse, 5 minutes' walk from Udaipur Junction", even though they share few words.
A vector database (or a vector index inside an ordinary database) stores those vectors and quickly finds the ones nearest to a query.
Retrieval-augmented generation (RAG) puts this to work in three steps:
- Retrieve — embed the question and fetch the most similar stored notes.
- Augment — add those notes to the context.
- Generate — the model answers using them, ideally saying which note it relied on.
question → embed → nearest 3 notes → [notes + question] → model → answerForgetting keeps long-term memory healthy. Common strategies:
- Expiry — some memories get an end date (a price quote is stale in a week).
- Recency weighting — older memories score lower when ranking results.
- Consolidation — many old episodes are replaced by one summary.
- Deletion on request — when a user asks to be forgotten, the data goes.
The shortcut
Rank memories by "relevant and still true", not relevance alone. A simple recipe multiplies the similarity score by a recency weight, so an old note must be a much better match to beat a fresh one.
The candidates
Note A (last month): similarity 0.80, recency weight 1.0. Note B (two years ago): similarity 0.90, recency weight 0.5.
The trap is trusting retrieval blindly. The nearest note is not always a correct one, and a stale note can contradict a newer fact. Keep dates on memories, prefer newer facts when they clash, and let the model say when nothing relevant was found.
Drills
Answer fast — trust the rule.
What does an embedding represent?
What are the three steps of retrieval-augmented generation, in order?
Note C has similarity 0.70 and recency weight 1.0; Note D has similarity 0.95 and recency weight 0.6. Using similarity × recency, which ranks higher?
A saved fare quote from last month keeps being used as current. Which forgetting strategy fits best?
Remember
- Embeddings store meaning as vectors; RAG retrieves the nearest notes, adds them, then generates.
- Shortcut: rank by "relevant and still true" — similarity weighted by recency.
- Trap: trusting the nearest match blindly; keep dates and prefer newer facts.
