Vector similarity is blind to time. In domains where freshness matters — news, prices, policies, support docs — a stale document that happens to embed close to the query can beat a newer, slightly-less-similar one. A freshness decay layer fixes that by multiplying each similarity score by a factor that shrinks with document age. This calculator lets you model that factor and see the re-ranked result before you wire it into your pipeline.
How it works
For each document you supply an age in days and a base similarity from your vector search. The tool computes a freshness factor with the model you choose and multiplies it into the score:
- Exponential:
factor = 0.5 ^ (age / half-life)— smooth, never zero. - Linear:
factor = max(0, 1 − age / cutoff)— straight-line drop to zero at the cutoff. - Step:
factor = 1whileage ≤ cutoff, otherwise a fixed penalty.
It then re-sorts the documents by the adjusted score so you can compare the original and recency-aware rankings.
Worked example
Suppose a user query about a software pricing plan retrieves these three candidates from a vector search:
| Document | Age (days) | Base similarity |
|---|---|---|
| Pricing guide 2023 (stale) | 540 | 0.91 |
| Feature comparison Jan 2024 | 170 | 0.87 |
| Current pricing page | 14 | 0.83 |
Without decay, the 2023 guide wins on similarity and is the top result — even though the pricing information it contains is likely outdated. With exponential decay and a 60-day half-life:
factor (540 days) = 0.5^(540/60) = 0.5^9 ≈ 0.002 → score ≈ 0.0018
factor (170 days) = 0.5^(170/60) = 0.5^2.8 ≈ 0.143 → score ≈ 0.124
factor (14 days) = 0.5^(14/60) ≈ 0.848 → score ≈ 0.704
The current pricing page now tops the ranking despite having the lowest base similarity. For a question about current pricing, this is the right result.
Choosing a decay model and half-life
The right half-life depends entirely on how quickly your domain’s content expires:
| Domain | Recommended half-life | Reason |
|---|---|---|
| Financial news, live prices | Hours to 1 day | Information is materially wrong within hours |
| News and current events | 1–3 days | Stories develop and context changes rapidly |
| Software documentation | 30–90 days | Versions ship; API signatures and UI change |
| Product descriptions | 60–180 days | Pricing and features update quarterly or less |
| Legal or policy references | 90–365 days | Amendments are periodic but significant |
| Scientific reference material | Years | Fundamental data rarely changes |
Use the step model when freshness is binary: content within a defined window is fully valid, anything outside is uniformly penalised. This suits domains like legal citation periods or regulatory filing dates.
Implementation notes
- Apply decay as a post-retrieval re-rank, not inside the approximate nearest-neighbour search itself. ANN indexes search on raw vectors; inject decay after retrieving the top-K candidates.
- Store timestamps as metadata on each document in the vector database. Computing age at query time from a stored
created_atfield is cheap; storing age as a static number means re-indexing whenever you change your decay window. - If fresh documents begin dominating obviously irrelevant matches, your half-life is too short. Lengthen it until the quality-freshness balance feels right on your evaluation set.