Home / Function/ similarity_search_by_image_with_relevance_score() — langchain Function Reference

similarity_search_by_image_with_relevance_score() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8f083180_e97d_01bc_d3a9_92f558f38aef["similarity_search_by_image_with_relevance_score()"]
  d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"]
  8f083180_e97d_01bc_d3a9_92f558f38aef -->|defined in| d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab
  561ae42b_0831_86cc_0c0f_9b97d4c4ec09["similarity_search_by_vector_with_relevance_scores()"]
  8f083180_e97d_01bc_d3a9_92f558f38aef -->|calls| 561ae42b_0831_86cc_0c0f_9b97d4c4ec09
  style 8f083180_e97d_01bc_d3a9_92f558f38aef fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/chroma/langchain_chroma/vectorstores.py lines 986–1024

    def similarity_search_by_image_with_relevance_score(
        self,
        uri: str,
        k: int = DEFAULT_K,
        filter: dict[str, str] | None = None,  # noqa: A002
        **kwargs: Any,
    ) -> list[tuple[Document, float]]:
        """Search for similar images based on the given image URI.

        Args:
            uri: URI of the image to search for.
            k: Number of results to return.
            filter: Filter by metadata.
            **kwargs: Additional arguments to pass to function.

        Returns:
            List of tuples containing documents similar to the query image and their
            similarity scores. 0th element in each tuple is a LangChain Document Object.
            The page content is b64 encoded img, metadata is default or defined by user.

        Raises:
            ValueError: If the embedding function does not support image embeddings.
        """
        if self._embedding_function is not None and hasattr(
            self._embedding_function, "embed_image"
        ):
            # Obtain image embedding
            # Assuming embed_image returns a single embedding
            image_embedding = self._embedding_function.embed_image(uris=[uri])

            # Perform similarity search based on the obtained embedding
            return self.similarity_search_by_vector_with_relevance_scores(
                embedding=image_embedding,
                k=k,
                filter=filter,
                **kwargs,
            )
        msg = "The embedding function must support image embedding."
        raise ValueError(msg)

Subdomains

Frequently Asked Questions

What does similarity_search_by_image_with_relevance_score() do?
similarity_search_by_image_with_relevance_score() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is similarity_search_by_image_with_relevance_score() defined?
similarity_search_by_image_with_relevance_score() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 986.
What does similarity_search_by_image_with_relevance_score() call?
similarity_search_by_image_with_relevance_score() calls 1 function(s): similarity_search_by_vector_with_relevance_scores.

Analyze Your Own Codebase

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

Try Supermodel Free