Retrieve documents from this graph store using MMR-traversal.
This strategy first retrieves the top fetch_k results by similarity to
the question. It then selects the top k results based on
maximum-marginal relevance using the given lambda_mult.
At each step, it considers the (remaining) documents from fetch_k as
well as any documents connected by edges to a selected document
retrieved based on similarity (a "root").
ammr_traversal_search(
self,
query: str,
*,
initial_roots: Sequence[str] = (),
k: int = 4,
depth: int = 2,
fetch_k: int = 100,
adjacent_k: int = 10,
lambda_mult: float = 0.5,
score_threshold: float = float('-inf'),
filter: dict[str, Any] | None = None,
**kwargs: Any = {}
) -> AsyncIterable[Document]| Name | Type | Description |
|---|---|---|
query* | str | The query string to search for. |
initial_roots | Sequence[str] | Default: ()Optional list of document IDs to use for initializing search.
The top |
k | int | Default: 4Number of Documents to return. Defaults to 4. |
fetch_k | int | Default: 100Number of initial Documents to fetch via similarity.
Will be added to the nodes adjacent to |
adjacent_k | int | Default: 10Number of adjacent Documents to fetch. Defaults to 10. |
depth | int | Default: 2Maximum depth of a node (number of edges) from a node retrieved via similarity. Defaults to 2. |
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. Defaults to 0.5. |
score_threshold | float | Default: float('-inf')Only documents with a score greater than or equal this threshold will be chosen. Defaults to -infinity. |
filter | dict[str, Any] | None | Default: NoneOptional metadata to filter the results. |
**kwargs | Any | Default: {}Additional keyword arguments. |