Replies: 1 comment 5 replies
-
To return similarity scores from a results = retriever.similarity_search_with_score(query="your_query", k=top_k)
for doc, score in results:
print(f"* [SIM={score:.3f}] {doc.page_content} [{doc.metadata}]") This will output the documents along with their similarity scores. Make sure you have set up your retriever as shown in the integration details: sparse_search_params = {"metric_type": "IP"}
dense_search_params = {"metric_type": "IP", "params": {}}
retriever = MilvusCollectionHybridSearchRetriever(
collection=collection,
rerank=RRFRanker(),
anns_fields=["dense_vector", "sparse_vector"],
field_embeddings=[dense_embedding_func, sparse_embedding_func],
field_search_params=[dense_search_params, sparse_search_params],
top_k=top_k,
text_field='text',
) For more detailed documentation, refer to the API reference [1][2]. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
In is there a way for me return the similarity score?
docs = retriever.aget_relevant_documents(question)
This only return a list of docs, but without similarity scores. In contrast, this following function return similarity scores:
So my question is, for MilvusCollectionHybridSearchRetriever, can I also get similarity scores with returned documents?
System Info
Beta Was this translation helpful? Give feedback.
All reactions