asimilarity_search_with_score_by_vector() — langchain Function Reference
Architecture documentation for the asimilarity_search_with_score_by_vector() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b["asimilarity_search_with_score_by_vector()"] bf62db79_4217_463c_798f_6f8528ed0d6e["Qdrant"] 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b -->|defined in| bf62db79_4217_463c_798f_6f8528ed0d6e 54148685_b625_1439_e4cf_0553492b20f9["asimilarity_search_with_score()"] 54148685_b625_1439_e4cf_0553492b20f9 -->|calls| 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b 503a0ffb_6858_79c6_16e8_e6b733ac6e1d["asimilarity_search_by_vector()"] 503a0ffb_6858_79c6_16e8_e6b733ac6e1d -->|calls| 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b da6088cd_8d2e_d514_0bcd_f8351efb05d6["_qdrant_filter_from_dict()"] 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b -->|calls| da6088cd_8d2e_d514_0bcd_f8351efb05d6 8825934a_277a_c22c_c57b_c1dbf765f2cc["_document_from_scored_point()"] 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b -->|calls| 8825934a_277a_c22c_c57b_c1dbf765f2cc style 261d8fc5_aa94_c7fc_9d68_eabaaa5ab85b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/qdrant/langchain_qdrant/vectorstores.py lines 630–722
async def asimilarity_search_with_score_by_vector(
self,
embedding: list[float],
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 embedding vector.
Args:
embedding: Embedding vector 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
AsyncQdrantClient.Search().
Returns:
List of documents most similar to the query text and distance for each.
"""
if self.async_client is None or isinstance(
self.async_client._client, AsyncQdrantLocal
):
msg = "QdrantLocal cannot interoperate with sync and async clients"
raise NotImplementedError(msg)
if filter is not None and isinstance(filter, dict):
warnings.warn(
"Using dict as a `filter` is deprecated. Please use qdrant-client "
"filters directly: "
"https://qdrant.tech/documentation/concepts/filtering/",
DeprecationWarning,
stacklevel=2,
)
qdrant_filter = self._qdrant_filter_from_dict(filter)
else:
qdrant_filter = filter
query_vector = embedding
if self.vector_name is not None:
query_vector = (self.vector_name, embedding) # type: ignore[assignment]
results = await self.async_client.search(
collection_name=self.collection_name,
query_vector=query_vector,
query_filter=qdrant_filter,
search_params=search_params,
limit=k,
offset=offset,
with_payload=True,
with_vectors=False, # LangChain does not expect vectors to be returned
score_threshold=score_threshold,
consistency=consistency,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does asimilarity_search_with_score_by_vector() do?
asimilarity_search_with_score_by_vector() is a function in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py.
Where is asimilarity_search_with_score_by_vector() defined?
asimilarity_search_with_score_by_vector() is defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py at line 630.
What does asimilarity_search_with_score_by_vector() call?
asimilarity_search_with_score_by_vector() calls 2 function(s): _document_from_scored_point, _qdrant_filter_from_dict.
What calls asimilarity_search_with_score_by_vector()?
asimilarity_search_with_score_by_vector() is called by 2 function(s): asimilarity_search_by_vector, asimilarity_search_with_score.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free