Home / Function/ similarity_search_with_score_by_vector() — langchain Function Reference

similarity_search_with_score_by_vector() — langchain Function Reference

Architecture documentation for the similarity_search_with_score_by_vector() function in in_memory.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  bc9209e2_2df4_4845_6a2a_f1a745b98d88["similarity_search_with_score_by_vector()"]
  6e491709_d60f_689d_8a1a_c760b54fd120["InMemoryVectorStore"]
  bc9209e2_2df4_4845_6a2a_f1a745b98d88 -->|defined in| 6e491709_d60f_689d_8a1a_c760b54fd120
  0ce5a306_acdd_dcdf_54b7_518eb6c91dee["similarity_search_with_score()"]
  0ce5a306_acdd_dcdf_54b7_518eb6c91dee -->|calls| bc9209e2_2df4_4845_6a2a_f1a745b98d88
  e59dcf6a_fb2f_6e50_714b_45aedbb12988["asimilarity_search_with_score()"]
  e59dcf6a_fb2f_6e50_714b_45aedbb12988 -->|calls| bc9209e2_2df4_4845_6a2a_f1a745b98d88
  f029e9d2_7f4e_370f_644b_6396cf0bc134["similarity_search_by_vector()"]
  f029e9d2_7f4e_370f_644b_6396cf0bc134 -->|calls| bc9209e2_2df4_4845_6a2a_f1a745b98d88
  22419bdc_697d_ae67_2f59_ca88dc465acc["_similarity_search_with_score_by_vector()"]
  bc9209e2_2df4_4845_6a2a_f1a745b98d88 -->|calls| 22419bdc_697d_ae67_2f59_ca88dc465acc
  style bc9209e2_2df4_4845_6a2a_f1a745b98d88 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/vectorstores/in_memory.py lines 334–356

    def similarity_search_with_score_by_vector(
        self,
        embedding: list[float],
        k: int = 4,
        filter: Callable[[Document], bool] | None = None,  # noqa: A002
        **_kwargs: Any,
    ) -> list[tuple[Document, float]]:
        """Search for the most similar documents to the given embedding.

        Args:
            embedding: The embedding to search for.
            k: The number of documents to return.
            filter: A function to filter the documents.

        Returns:
            A list of tuples of `Document` objects and their similarity scores.
        """
        return [
            (doc, similarity)
            for doc, similarity, _ in self._similarity_search_with_score_by_vector(
                embedding=embedding, k=k, filter=filter
            )
        ]

Subdomains

Frequently Asked Questions

What does similarity_search_with_score_by_vector() do?
similarity_search_with_score_by_vector() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/in_memory.py.
Where is similarity_search_with_score_by_vector() defined?
similarity_search_with_score_by_vector() is defined in libs/core/langchain_core/vectorstores/in_memory.py at line 334.
What does similarity_search_with_score_by_vector() call?
similarity_search_with_score_by_vector() calls 1 function(s): _similarity_search_with_score_by_vector.
What calls similarity_search_with_score_by_vector()?
similarity_search_with_score_by_vector() is called by 3 function(s): asimilarity_search_with_score, similarity_search_by_vector, similarity_search_with_score.

Analyze Your Own Codebase

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

Try Supermodel Free