Home / Function/ amax_marginal_relevance_search_by_vector() — langchain Function Reference

amax_marginal_relevance_search_by_vector() — langchain Function Reference

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

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  0ec7a2c6_a51b_581a_7363_858cc7222d22["amax_marginal_relevance_search_by_vector()"]
  2d095452_70a7_4606_a1b1_4650d16b5343["Qdrant"]
  0ec7a2c6_a51b_581a_7363_858cc7222d22 -->|defined in| 2d095452_70a7_4606_a1b1_4650d16b5343
  32137f96_4258_744f_9902_4d022e824899["amax_marginal_relevance_search()"]
  32137f96_4258_744f_9902_4d022e824899 -->|calls| 0ec7a2c6_a51b_581a_7363_858cc7222d22
  5b58fc45_0beb_27f4_0065_afd49a62b315["amax_marginal_relevance_search_with_score_by_vector()"]
  0ec7a2c6_a51b_581a_7363_858cc7222d22 -->|calls| 5b58fc45_0beb_27f4_0065_afd49a62b315
  style 0ec7a2c6_a51b_581a_7363_858cc7222d22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/qdrant/langchain_qdrant/vectorstores.py lines 918–982

    async def amax_marginal_relevance_search_by_vector(
        self,
        embedding: list[float],
        k: int = 4,
        fetch_k: int = 20,
        lambda_mult: float = 0.5,
        filter: MetadataFilter | None = None,  # noqa: A002
        search_params: models.SearchParams | None = None,
        score_threshold: float | None = None,
        consistency: models.ReadConsistency | None = None,
        **kwargs: Any,
    ) -> list[Document]:
        """Return docs selected using the maximal marginal relevance.

        Maximal marginal relevance optimizes for similarity to query AND diversity
        among selected documents.

        Args:
            embedding: Embedding vector to look up documents similar to.
            k: Number of `Document` objects to return.
            fetch_k: Number of `Document` to fetch to pass to MMR algorithm.
            lambda_mult: Number between `0` and `1` that determines the degree
                        of diversity among the results with `0` corresponding
                        to maximum diversity and `1` to minimum diversity.
            filter: Filter by metadata.
            search_params: Additional search params
            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 `Document` objects selected by maximal marginal relevance and
            distance for each.

        """
        results = await self.amax_marginal_relevance_search_with_score_by_vector(
            embedding,
            k=k,
            fetch_k=fetch_k,
            lambda_mult=lambda_mult,
            filter=filter,
            search_params=search_params,
            score_threshold=score_threshold,
            consistency=consistency,
            **kwargs,
        )
        return list(map(itemgetter(0), results))

Domain

Subdomains

Frequently Asked Questions

What does amax_marginal_relevance_search_by_vector() do?
amax_marginal_relevance_search_by_vector() is a function in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py.
Where is amax_marginal_relevance_search_by_vector() defined?
amax_marginal_relevance_search_by_vector() is defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py at line 918.
What does amax_marginal_relevance_search_by_vector() call?
amax_marginal_relevance_search_by_vector() calls 1 function(s): amax_marginal_relevance_search_with_score_by_vector.
What calls amax_marginal_relevance_search_by_vector()?
amax_marginal_relevance_search_by_vector() is called by 1 function(s): amax_marginal_relevance_search.

Analyze Your Own Codebase

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

Try Supermodel Free