ObjectNameDisplay
ObjectNameDisplay

Reputation: 493

Do LOWER results from Chroma's similarity_with_score mean HIGHER Accuracy?

I have a quick question: I'm using the Chroma vector store with LangChain.

And I brought up a simple docsearch with Chroma.from_texts. I was initially very confused because i thought the similarity_score_with_score would be higher for queries that are close to answers, but it seems from my testing the opposite is true. Is this becasue it's returning the 'distance' between the two vectors when it searches? I was looking at docs but it only says "List of Documents most similar to the query and score for each" but doesnt explain what 'score' is

Doc reference https://python.langchain.com/en/latest/reference/modules/vectorstores.html?highlight=similarity_search#langchain.vectorstores.Annoy.similarity_search_with_score Can also give more info on the (small to start) dataset im using and queries i tested with.

Upvotes: 4

Views: 8444

Answers (2)

user195227
user195227

Reputation: 33

That's right. You can check in the definition, below, of the Function:

enter image description here

I take the opportunity to ask the following question:

I'm working with Chroma. As you can see I am also using similarity_search_with_score(), see below. I would like to confirm with you the following: Do you also use distance_metric="cos" for CHROMA? The documentation doesn't explicitly say this, but I believe it's possible, since it has this parameter **kwargs.

db = Chroma.from_documents(texts, embeddings)

docs_score = db.similarity_search_with_score(query=query, distance_metric="cos", k = 6)

enter image description here

Observation:

I prefer to use cosine to try to avoid the curse of high dimensionality, not depending on scale, etc etc.

Thanks!

Upvotes: 1

Dattatray
Dattatray

Reputation: 543

as you said, it's returning the 'distance' between the two vectors when it searches. those vectors are similar will be placed closer to each other in vector space. lower distance means documents are more similar to each other.

Upvotes: 7

Related Questions