Home / Function/ similarity_search_by_vector() — langchain Function Reference

similarity_search_by_vector() — langchain Function Reference

Architecture documentation for the similarity_search_by_vector() function in vectorstores.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  76615968_7cd6_d5f7_a619_c032edfc26cb["similarity_search_by_vector()"]
  d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"]
  76615968_7cd6_d5f7_a619_c032edfc26cb -->|defined in| d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab
  c0b7a4cd_c01b_9d43_bd62_7b531e7e6b42["similarity_search_by_image()"]
  c0b7a4cd_c01b_9d43_bd62_7b531e7e6b42 -->|calls| 76615968_7cd6_d5f7_a619_c032edfc26cb
  606e28c0_f5b8_541a_3421_640b6c15492e["_results_to_docs()"]
  76615968_7cd6_d5f7_a619_c032edfc26cb -->|calls| 606e28c0_f5b8_541a_3421_640b6c15492e
  style 76615968_7cd6_d5f7_a619_c032edfc26cb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/chroma/langchain_chroma/vectorstores.py lines 756–784

    def similarity_search_by_vector(
        self,
        embedding: list[float],
        k: int = DEFAULT_K,
        filter: dict[str, str] | None = None,  # noqa: A002
        where_document: dict[str, str] | None = None,
        **kwargs: Any,
    ) -> list[Document]:
        """Return docs most similar to embedding vector.

        Args:
            embedding: Embedding to look up documents similar to.
            k: Number of Documents 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 `Document` objects most similar to the query vector.
        """
        results = self.__query_collection(
            query_embeddings=[embedding],
            n_results=k,
            where=filter,
            where_document=where_document,
            **kwargs,
        )
        return _results_to_docs(results)

Subdomains

Frequently Asked Questions

What does similarity_search_by_vector() do?
similarity_search_by_vector() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is similarity_search_by_vector() defined?
similarity_search_by_vector() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 756.
What does similarity_search_by_vector() call?
similarity_search_by_vector() calls 1 function(s): _results_to_docs.
What calls similarity_search_by_vector()?
similarity_search_by_vector() is called by 1 function(s): similarity_search_by_image.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free