Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents.
max_marginal_relevance_search(
self,
query: str,
k: int = 4,
fetch_k: int = 20,
lambda_mult: float = 0.5,
filter: dict[str, Any] | None = None,
**kwargs: Any = {}
) -> list[Document]| Name | Type | Description |
|---|---|---|
query* | str | Query to look up documents similar to. |
k | int | Default: 4Number of Documents to return. |
fetch_k | int | Default: 20Number of Documents to fetch to pass to MMR algorithm. |
lambda_mult | float | Default: 0.5Number 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 | dict[str, Any] | None | Default: NoneFilter on the metadata to apply. |
**kwargs | Any | Default: {}Additional arguments are ignored. |