MmrHelper#
- class langchain_astradb.utils.mmr_helper.MmrHelper(k: int, query_embedding: list[float], lambda_mult: float = 0.5, score_threshold: float = -inf)[source]#
Helper for executing an MMR traversal query.
- Parameters:
query_embedding (list[float]) β The embedding of the query to use for scoring.
lambda_mult (float) β 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. Defaults to 0.5.
score_threshold (float) β Only documents with a score greater than or equal this threshold will be chosen. Defaults to -infinity.
k (int)
Create a new Traversal MMR helper.
Attributes
Methods
__init__
(k,Β query_embedding[,Β lambda_mult,Β ...])Create a new Traversal MMR helper.
add_candidates
(candidates)Add candidates to the consideration set.
Return the IDs of the candidates.
pop_best
()Select and pop the best item being considered.
- __init__(k: int, query_embedding: list[float], lambda_mult: float = 0.5, score_threshold: float = -inf) None [source]#
Create a new Traversal MMR helper.
- Parameters:
k (int)
query_embedding (list[float])
lambda_mult (float)
score_threshold (float)
- Return type:
None
- add_candidates(candidates: dict[str, list[float]]) None [source]#
Add candidates to the consideration set.
- Parameters:
candidates (dict[str, list[float]])
- Return type:
None