From 133874cc0b2dcc30e759c61fadf036a0f3d0cec7 Mon Sep 17 00:00:00 2001 From: seehi <6580@pm.me> Date: Tue, 14 May 2024 15:56:52 +0800 Subject: [PATCH] format --- metagpt/rag/benchmark/base.py | 2 +- metagpt/rag/factories/ranker.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/metagpt/rag/benchmark/base.py b/metagpt/rag/benchmark/base.py index c1fd297d9..b5d265b35 100644 --- a/metagpt/rag/benchmark/base.py +++ b/metagpt/rag/benchmark/base.py @@ -121,7 +121,7 @@ def mean_reciprocal_rank(self, nodes: list[NodeWithScore], reference_docs: list[ return mrr_sum return mrr_sum - + async def semantic_similarity(self, response: str, reference: str) -> float: result = await self.evaluator.aevaluate( response=response, diff --git a/metagpt/rag/factories/ranker.py b/metagpt/rag/factories/ranker.py index b75745a1f..7abda162a 100644 --- a/metagpt/rag/factories/ranker.py +++ b/metagpt/rag/factories/ranker.py @@ -8,11 +8,11 @@ from metagpt.rag.rankers.object_ranker import ObjectSortPostprocessor from metagpt.rag.schema import ( BaseRankerConfig, + BGERerankConfig, + CohereRerankConfig, ColbertRerankConfig, LLMRankerConfig, ObjectRankerConfig, - CohereRerankConfig, - BGERerankConfig ) @@ -60,13 +60,15 @@ def _create_cohere_rerank(self, config: CohereRerankConfig, **kwargs) -> LLMRera def _create_bge_rerank(self, config: BGERerankConfig, **kwargs) -> LLMRerank: try: - from llama_index.postprocessor.flag_embedding_reranker import FlagEmbeddingReranker + from llama_index.postprocessor.flag_embedding_reranker import ( + FlagEmbeddingReranker, + ) except ImportError: raise ImportError( "`llama-index-postprocessor-flag-embedding-reranker` package not found, please run `pip install llama-index-postprocessor-flag-embedding-reranker`" ) return FlagEmbeddingReranker(**config.model_dump()) - + def _create_object_ranker(self, config: ObjectRankerConfig, **kwargs) -> LLMRerank: return ObjectSortPostprocessor(**config.model_dump())