RAGchain.reranker.importance package
Submodules
RAGchain.reranker.importance.simple_importance module
- class RAGchain.reranker.importance.simple_importance.SimpleImportanceReranker
Bases:
BaseReranker
Rerank passages by their importance only. It is simple reranker for importance-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.importance.weighted_importance module
- class RAGchain.reranker.importance.weighted_importance.WeightedImportanceReranker(importance_weight: float = 0.5)
Bases:
BaseReranker
Rerank passages by their importance and relevance score. First, relevance score and importance must be normalized to [0, 1] range. And calculate the combined score by the following formula:
score = (weight) * importance + (1 - weight) * relevance_score
The larger the weight, the more important the importance is.
- 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.