How do you handle time in retrieval - 'latest' queries, superseded documents, and questions about the past?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Embeddings have no concept of time. 'The 2024 policy' and 'the 2025 policy' are near-identical semantically, so cosine similarity cannot tell you which is current, and the default behaviour is to return whichever happens to embed slightly closer. That is how RAG systems confidently quote expired policies.
Full worked answer
Embeddings have no concept of time. 'The 2024 policy' and 'the 2025 policy' are near-identical semantically, so cosine similarity cannot tell you which is current, and the default behaviour is to return whichever happens to embed slightly closer. That is how RAG systems confidently quote expired policies.
What I would do:
Model time explicitly in metadata. Not just ingested_at, which is what people default to and is nearly useless. You want event time versus validity time: when the document was authored, when the policy takes effect, when it expires, and a superseded_by pointer. A contract signed in 2023 effective 2025 breaks any single-timestamp model.
Resolve relative time in the query. 'Last quarter' has to become an absolute range before retrieval, using the request timestamp. The query rewriter does this, and it is a routine source of bugs when the user's timezone and the server's disagree.
Filter, then decay, in that order. Hard filters for correctness: exclude expired documents, restrict to the asked-for period. Soft recency boost for preference, applied after retrieval, at rerank or fusion time. Never bake recency into the embedding.
score = relevance * exp(-age_days / tau) # tau set per corpus
Tau depends entirely on the domain. Engineering docs go stale in months, employment law in years. There is no universal value, so measure it.
Default to current, but keep history reachable. Most queries want the current state. So default the filter to non-superseded documents, and let explicit historical intent ('what did we do in 2022') lift the filter. Deleting superseded documents is the wrong fix: you lose audit and history.
The evaluation trap: golden sets go stale. A question whose correct answer was the 2025 policy silently becomes wrong when the 2026 one lands, so your eval reports a regression that is actually correct behaviour. Version the golden set against a corpus snapshot.
What a good answer covers
- Embeddings have no concept of time
- That is how RAG systems confidently quote expired policies
- Not just ingested_at, which is what people default to and is nearly useless
- You want event time versus validity time
- A contract signed in 2023 effective 2025 breaks any single-timestamp model
Key terms: Model time explicitly in metadata
In the glossary: Cosine similarity · RAG · Golden set
Interviewer follow-ups to expect
How would you pick the decay constant tau for a given corpus rather than guessing?
A user asks 'what is our parental leave policy' and there are three versions. What exactly does your retriever return?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep