VectorStoreRetrieverMMRSearchKwargs: {
    fetchK?: number;
    lambda?: number;
}

Options for configuring a maximal marginal relevance (MMR) search when using the VectorStoreRetriever.

These parameters control how the MMR algorithm balances relevance to the query and diversity among the retrieved documents.

Fields:

  • fetchK (optional): Specifies the initial number of documents to fetch before applying the MMR algorithm. This larger set provides a pool of documents from which the algorithm can select the most diverse results based on relevance to the query.

  • lambda (optional): A value between 0 and 1 that determines the balance between relevance and diversity:

    • A lambda of 0 maximizes diversity among the results, prioritizing varied content.
    • A lambda of 1 maximizes similarity to the query, prioritizing relevance. Values between 0 and 1 provide a mix of relevance and diversity.