Home / Function/ max_marginal_relevance_search_by_vector() — langchain Function Reference

max_marginal_relevance_search_by_vector() — langchain Function Reference

Architecture documentation for the max_marginal_relevance_search_by_vector() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/vectorstores/base.py lines 724–749

    def max_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]:
        """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.
        """
        raise NotImplementedError

Subdomains

Frequently Asked Questions

What does max_marginal_relevance_search_by_vector() do?
max_marginal_relevance_search_by_vector() is a function in the langchain codebase, defined in libs/core/langchain_core/vectorstores/base.py.
Where is max_marginal_relevance_search_by_vector() defined?
max_marginal_relevance_search_by_vector() is defined in libs/core/langchain_core/vectorstores/base.py at line 724.

Analyze Your Own Codebase

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

Try Supermodel Free