fix(rag): Fix CrossEncoderRanker bug of EmbeddingRetriever (#1504)

Co-authored-by: aries_ckt <916701291@qq.com>
This commit is contained in:
ivanzhu 2024-05-10 13:32:58 +08:00 committed by GitHub
parent 87a67cce7d
commit 8eb64d7311
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View File

@ -219,7 +219,7 @@ class CrossEncoderRanker(Ranker):
rank_scores = self._model.predict(sentences=query_content_pairs)
for candidate, score in zip(candidates_with_scores, rank_scores):
candidate.score = score
candidate.score = float(score)
new_candidates_with_scores = sorted(
candidates_with_scores, key=lambda x: x.score, reverse=True

View File

@ -82,7 +82,7 @@ class ChromaStore(VectorStoreBase):
# client_settings=chroma_settings,
client=client,
collection_metadata=collection_metadata,
)
) # type: ignore
def similar_search(
self, text, topk, filters: Optional[MetadataFilters] = None

View File

@ -93,7 +93,8 @@ class PGVectorStore(VectorStoreBase):
List[str]: chunk ids.
"""
lc_documents = [Chunk.chunk2langchain(chunk) for chunk in chunks]
return self.vector_store_client.from_documents(lc_documents)
self.vector_store_client.from_documents(lc_documents)
return [str(chunk.chunk_id) for chunk in lc_documents]
def delete_vector_name(self, vector_name: str):
"""Delete vector by name.
@ -109,4 +110,5 @@ class PGVectorStore(VectorStoreBase):
Args:
ids(str): vector ids, separated by comma.
"""
return self.vector_store_client.delete(ids)
delete_ids = ids.split(",")
return self.vector_store_client.delete(delete_ids)