temporal-rag
A post-retrieval layer for RAG pipelines that filters out expired documents, applies time decay and freshness scoring, and reranks results so a fresh, still-valid document outranks an outdated one.
temporal-rag runs downstream of any vector search system and adds a validity filter that removes expired documents before scoring, a classifier that labels each document as static, versioned or event-based, an exponential decay scorer, a recency scorer normalized within the candidate pool, an event-relevance gate that stops freshness from overriding raw relevance, and a hybrid reranker that combines vector similarity with these temporal signals.
An advanced module adds a pattern that keeps a weak document only alongside a fresher partner, confidence tiers based on score margin and conflict, rejection-code logging keyed by query id, a hard date-range filter parsed from the query text, adaptive weighting of the temporal signal, a freshness report per document, and deduplication that collapses chains of superseding versions. It depends only on numpy and the Python standard library, and its demo uses a deterministic TF-IDF embedder so output is reproducible without an API key.