similarity_search_with_vectors() — langchain Function Reference
Architecture documentation for the similarity_search_with_vectors() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5198b466_cc00_8aa0_1bbb_9868b85bbc85["similarity_search_with_vectors()"] babbef04_3a0c_25f4_58a8_9d3209d5867e["Chroma"] 5198b466_cc00_8aa0_1bbb_9868b85bbc85 -->|defined in| babbef04_3a0c_25f4_58a8_9d3209d5867e 692f7005_1418_c3de_68d7_aa0b54137ac8["_results_to_docs_and_vectors()"] 5198b466_cc00_8aa0_1bbb_9868b85bbc85 -->|calls| 692f7005_1418_c3de_68d7_aa0b54137ac8 style 5198b466_cc00_8aa0_1bbb_9868b85bbc85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/chroma/langchain_chroma/vectorstores.py lines 859–902
def similarity_search_with_vectors(
self,
query: str,
k: int = DEFAULT_K,
filter: dict[str, str] | None = None, # noqa: A002
where_document: dict[str, str] | None = None,
**kwargs: Any,
) -> list[tuple[Document, np.ndarray]]:
"""Run similarity search with Chroma with vectors.
Args:
query: Query text to search for.
k: Number of results to return.
filter: Filter by metadata.
where_document: dict used to filter by the document contents.
E.g. {"$contains": "hello"}.
kwargs: Additional keyword arguments to pass to Chroma collection query.
Returns:
List of documents most similar to the query text and
embedding vectors for each.
"""
include = ["documents", "metadatas", "embeddings"]
if self._embedding_function is None:
results = self.__query_collection(
query_texts=[query],
n_results=k,
where=filter,
where_document=where_document,
include=include,
**kwargs,
)
else:
query_embedding = self._embedding_function.embed_query(query)
results = self.__query_collection(
query_embeddings=[query_embedding],
n_results=k,
where=filter,
where_document=where_document,
include=include,
**kwargs,
)
return _results_to_docs_and_vectors(results)
Domain
Subdomains
Source
Frequently Asked Questions
What does similarity_search_with_vectors() do?
similarity_search_with_vectors() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is similarity_search_with_vectors() defined?
similarity_search_with_vectors() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 859.
What does similarity_search_with_vectors() call?
similarity_search_with_vectors() calls 1 function(s): _results_to_docs_and_vectors.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free