reciprocal_rank_stage#

langchain_mongodb.pipelines.reciprocal_rank_stage(score_field: str, penalty: float = 0, **kwargs: Any) List[Dict[str, Any]][source]#

Stage adds Reciprocal Rank Fusion weighting.

First, it pushes documents retrieved from previous stage into a temporary sub-document. It then unwinds to establish the rank to each and applies the penalty.

Args:

score_field: A unique string to identify the search being ranked penalty: A non-negative float. extra_fields: Any fields other than text_field that one wishes to keep.

Returns:

RRF score :=

rac{1}{rank + penalty} with rank in [1,2,..,n]

Parameters:
  • score_field (str)

  • penalty (float)

  • kwargs (Any)

Return type:

List[Dict[str, Any]]