Skip to content

How to get the similarity between query and embedding when using the Retriever? #22887

Closed Answered by dosubot bot
Ma-Zijing asked this question in Q&A
Discussion options

You must be logged in to vote

To get the similarity scores between a query and the embeddings when using the Retriever in your RAG approach, you can use the similarity_search_with_score method provided by the Chroma class in the LangChain library. This method returns the documents most similar to the query along with their similarity scores.

Here is an example of how you can use this method:

# vector database
vectorstore = Chroma.from_documents(documents=all_splits, embedding=OpenAIEmbeddings())

# The retriever
retriever = vectorstore.as_retriever(search_type="similarity", search_kwargs={"k": top_k})

# prompt input values
input_dict = {
    "hardware_components_list": static_dict["hardware_components_list"],
    "r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@anudevmanjusatheesh
Comment options

Answer selected by Ma-Zijing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants