similarity_search_with_score() — langchain Function Reference
Architecture documentation for the similarity_search_with_score() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 39b56a94_734a_4e6b_c1e1_da8cc30168e8["similarity_search_with_score()"] bf62db79_4217_463c_798f_6f8528ed0d6e["Qdrant"] 39b56a94_734a_4e6b_c1e1_da8cc30168e8 -->|defined in| bf62db79_4217_463c_798f_6f8528ed0d6e c00c442a_f0df_4290_b7d7_342034350936["similarity_search()"] c00c442a_f0df_4290_b7d7_342034350936 -->|calls| 39b56a94_734a_4e6b_c1e1_da8cc30168e8 f0f2e1d5_1103_9db4_608a_c6ac75010259["_similarity_search_with_relevance_scores()"] f0f2e1d5_1103_9db4_608a_c6ac75010259 -->|calls| 39b56a94_734a_4e6b_c1e1_da8cc30168e8 6c8c9cf1_343a_b7b2_1ac5_f0f159c55037["similarity_search_with_score_by_vector()"] 39b56a94_734a_4e6b_c1e1_da8cc30168e8 -->|calls| 6c8c9cf1_343a_b7b2_1ac5_f0f159c55037 ce92a056_502f_c4a0_9d88_124ae4b56bb5["_embed_query()"] 39b56a94_734a_4e6b_c1e1_da8cc30168e8 -->|calls| ce92a056_502f_c4a0_9d88_124ae4b56bb5 style 39b56a94_734a_4e6b_c1e1_da8cc30168e8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/qdrant/langchain_qdrant/vectorstores.py lines 306–361
def similarity_search_with_score(
self,
query: str,
k: int = 4,
filter: MetadataFilter | None = None, # noqa: A002
search_params: models.SearchParams | None = None,
offset: int = 0,
score_threshold: float | None = None,
consistency: models.ReadConsistency | None = None,
**kwargs: Any,
) -> list[tuple[Document, float]]:
"""Return docs most similar to query.
Args:
query: Text to look up documents similar to.
k: Number of Documents to return.
filter: Filter by metadata.
search_params: Additional search params
offset:
Offset of the first result to return.
May be used to paginate results.
Note: large offset values may cause performance issues.
score_threshold:
Define a minimal score threshold for the result.
If defined, less similar results will not be returned.
Score of the returned result might be higher or smaller than the
threshold depending on the Distance function used.
E.g. for cosine similarity only higher scores will be returned.
consistency:
Read consistency of the search. Defines how many replicas should be
queried before returning the result.
Values:
- int - number of replicas to query, values should present in all
queried replicas
- 'majority' - query all replicas, but return values present in the
majority of replicas
- 'quorum' - query the majority of replicas, return values present in
all of them
- 'all' - query all replicas, and return values present in all replicas
**kwargs:
Any other named arguments to pass through to QdrantClient.search()
Returns:
List of documents most similar to the query text and distance for each.
"""
return self.similarity_search_with_score_by_vector(
self._embed_query(query),
k,
filter=filter,
search_params=search_params,
offset=offset,
score_threshold=score_threshold,
consistency=consistency,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does similarity_search_with_score() do?
similarity_search_with_score() is a function in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py.
Where is similarity_search_with_score() defined?
similarity_search_with_score() is defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py at line 306.
What does similarity_search_with_score() call?
similarity_search_with_score() calls 2 function(s): _embed_query, similarity_search_with_score_by_vector.
What calls similarity_search_with_score()?
similarity_search_with_score() is called by 2 function(s): _similarity_search_with_relevance_scores, similarity_search.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free