Type Alias MaxMarginalRelevanceSearchOptions<FilterType>

MaxMarginalRelevanceSearchOptions<FilterType>: {
    fetchK?: number;
    filter?: FilterType;
    k: number;
    lambda?: number;
}

Options for configuring a maximal marginal relevance (MMR) search.

MMR search optimizes for both similarity to the query and diversity among the results, balancing the retrieval of relevant documents with variation in the content returned.

Fields:

  • fetchK (optional): The initial number of documents to retrieve from the vector store 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.

  • filter (optional): A filter of type FilterType to refine the search results, allowing additional conditions to target specific subsets of documents.

  • k: The number of documents to return in the final results. This is the primary count of documents that are most relevant to the query.

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

    • A lambda of 0 emphasizes diversity, maximizing content variation.
    • A lambda of 1 emphasizes similarity to the query, focusing on relevance. Values between 0 and 1 provide a mix of relevance and diversity.

Type Parameters

  • FilterType

    The type used for filtering results, as defined by the vector store.