RAGchain.reranker.time package
Submodules
RAGchain.reranker.time.simple_time module
- class RAGchain.reranker.time.simple_time.SimpleTimeReranker
Bases:
BaseReranker
Rerank passages by their content_datetime only. It is simple reranker for time-aware RAG.
- invoke(input: Input, config: RunnableConfig | None = None) Output
Transform a single input into an output. Override to implement.
- Args:
input: The input to the runnable. config: A config to use when invoking the runnable.
The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details.
- Returns:
The output of the runnable.
RAGchain.reranker.time.weighted_time module
- class RAGchain.reranker.time.weighted_time.WeightedTimeReranker(decay_rate: float = 0.01)
Bases:
BaseReranker
Rerank passages by their content_datetime and relevance score. First, relevance score must be normalized to [0, 1] range. And calculate the combined score by the following formula:
score = (1 - decay_rate) ** hours_passed + relevance_score
The larger the decay_rate, the score from the past will be lowed.
- invoke(input: Input, config: RunnableConfig | None = None) Output
Transform a single input into an output. Override to implement.
- Args:
input: The input to the runnable. config: A config to use when invoking the runnable.
The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details.
- Returns:
The output of the runnable.