Skip to main content
When you call recall() or context(), Remem doesn’t return the memory with the highest cosine similarity — it returns the memory that is most useful right now. That distinction matters. A semantically identical memory stored six months ago is usually less useful than one stored yesterday. A fact you explicitly marked as important should surface even when the query only loosely matches. Remem’s hybrid scoring formula balances all three signals to get you there.

The Formula

The weights are fixed: semantic meaning carries the most influence, recency keeps results fresh, and importance gives you a lever to pin high-value facts to the top of results.

The Three Signals

How semantically similar is the stored memory to your query?This is what makes semantic search work. You don’t need exact keyword matches. You ask "where does this user live?" and the memory "User is based in Lagos, Nigeria" scores high because the meaning aligns — not because the words overlap.Cosine similarity is computed against the embedding of your query using the same model that embedded the original memory. The score ranges from 0.0 (no relationship) to 1.0 (identical meaning).
How recently was the memory stored or last accessed?Recency decays exponentially over time. A memory from yesterday scores close to 1.0; the same memory from six months ago might score 0.12. This prevents stale facts from outranking fresh ones when semantic similarity is equal.You don’t control recency directly — it is computed automatically from the memory’s timestamp. The practical implication: if a user updates their location, the newer memory will naturally outrank the older one without you having to delete anything.
How important did you mark this memory at store time?You set this with the importance parameter when calling remember(). The value ranges from 0.0 to 1.0 and defaults to 0.5. A higher value gives the memory a small but consistent boost across all future retrievals — useful for facts you always want surfaced regardless of recency.
Use importance=0.9 for stable facts like name, location, plan type, or communication preferences. These facts should always surface, even when they are months old.

Score Detail

Every search result includes a full breakdown of how it was ranked. You never have to guess why a memory surfaced — or didn’t.
The score_detail object looks like this:
Every result from recall() and context() includes score_detail. Use it when debugging unexpected retrieval behaviour — it shows you exactly which signal is driving the rank.

Tuning min_score

The min_score parameter controls the minimum final score a memory must reach to be included in results. The default is 0.70.
Setting min_score=0.0 in production will return every stored memory, sorted by score. This is useful for debugging but will increase latency and token usage for high-volume users.

Practical Example: Recency in Action

The table below shows how the same semantic content can rank very differently depending on when it was stored. The query is "where does this user live?". The newest Lagos memory wins by a wide margin, even though the content is identical to the six-month-old version. Recency ensures your agent is always working with the most current information — without you having to manually delete outdated memories.