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 base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  de285da4_b173_4819_fcbf_8e87d10a1a77["amax_marginal_relevance_search_by_vector()"]
  6c336ac6_f55c_1ad7_6db3_73dbd71fb625["VectorStore"]
  de285da4_b173_4819_fcbf_8e87d10a1a77 -->|defined in| 6c336ac6_f55c_1ad7_6db3_73dbd71fb625
  style de285da4_b173_4819_fcbf_8e87d10a1a77 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/vectorstores/base.py lines 751–784

    async def amax_marginal_relevance_search_by_vector(
        self,
        embedding: list[float],
        k: int = 4,
        fetch_k: int = 20,
        lambda_mult: float = 0.5,
        **kwargs: Any,
    ) -> list[Document]:
        """Async return docs selected using the maximal marginal relevance.

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

        Args:
            embedding: Embedding to look up documents similar to.
            k: Number of `Document` objects to return.
            fetch_k: Number of `Document` objects 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.
            **kwargs: Arguments to pass to the search method.

        Returns:
            List of `Document` objects selected by maximal marginal relevance.
        """
        return await run_in_executor(
            None,
            self.max_marginal_relevance_search_by_vector,
            embedding,
            k=k,
            fetch_k=fetch_k,
            lambda_mult=lambda_mult,
            **kwargs,
        )

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/core/langchain_core/vectorstores/base.py.
Where is amax_marginal_relevance_search_by_vector() defined?
amax_marginal_relevance_search_by_vector() is defined in libs/core/langchain_core/vectorstores/base.py at line 751.

Analyze Your Own Codebase

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

Try Supermodel Free