Package com.tnsai.intelligence.rag
Class TemporalRAGStrategy
java.lang.Object
com.tnsai.intelligence.rag.TemporalRAGStrategy
- All Implemented Interfaces:
RAGStrategy
Re-ranks content-relevant child hits with bounded time decay.
Freshness affects only twenty percent of the default score multiplier; the remaining relevance floor protects a clearly relevant older document from being displaced solely because another document is newer. Undated documents receive the conservative floor. Small future-clock skew is clamped to the retrieval instant, while excessive future dates fail loudly.
- Since:
- 0.13.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTemporalRAGStrategy(RAGStrategy childStrategy, TemporalIndex index, Set<String> allowedSources, Clock clock, Duration halfLife, double relevanceFloor, Duration maxFutureSkew) Creates a temporal retrieval strategy. -
Method Summary
Modifier and TypeMethodDescriptionname()Returns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").retrieve(String query, RAGContext context) Retrieves documents relevant to the given query.
-
Field Details
-
DEFAULT_HALF_LIFE
Default interval after which the freshness component halves. -
DEFAULT_RELEVANCE_FLOOR
public static final double DEFAULT_RELEVANCE_FLOORDefault minimum fraction of content relevance retained.- See Also:
-
DEFAULT_MAX_FUTURE_SKEW
Default tolerated producer/consumer clock skew.
-
-
Constructor Details
-
TemporalRAGStrategy
public TemporalRAGStrategy(RAGStrategy childStrategy, TemporalIndex index, Set<String> allowedSources, Clock clock, Duration halfLife, double relevanceFloor, Duration maxFutureSkew) Creates a temporal retrieval strategy.- Parameters:
childStrategy- strategy producing content-relevant candidatesindex- indexed documents and canonical timestampsallowedSources- selected source groups; empty allows every groupclock- retrieval clock, injectable for deterministic behaviorhalfLife- interval after which freshness decays by halfrelevanceFloor- minimum content-score multiplier, from zero to onemaxFutureSkew- tolerated future timestamp offset
-
-
Method Details
-
name
Description copied from interface:RAGStrategyReturns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").Names are compared case-insensitively using
Locale.ROOT.- Specified by:
namein interfaceRAGStrategy- Returns:
- the strategy name, never null
-
retrieve
Description copied from interface:RAGStrategyRetrieves documents relevant to the given query.Every returned document must exactly match all metadata filters in the context. Implementations apply that constraint before limiting the result to
RAGContext.maxResults().- Specified by:
retrievein interfaceRAGStrategy- Parameters:
query- the search query (never null)context- retrieval parameters (max results, min score, exact metadata filters)- Returns:
- an unmodifiable list of retrieved documents, sorted by descending relevance
-