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.