mbrs.selectors.base module#
- class mbrs.selectors.base.Selector(cfg: Config)[source]#
Bases:
ABCSelector base class.
- class Output(idx: list[int], sentence: list[str], score: list[float])[source]#
Bases:
objectidx (list[int]): Index numbers of the n-best hypotheses.
sentence (list[str]): Sentences of the n-best hypotheses.
score (list[float]): Scores of the n-best hypotheses.
- argbest(x: Tensor, maximize: bool = True) Tensor[source]#
Return the index of the best element.
- Parameters:
x (Tensor) – Input 1-D array.
maximize (bool) – Whether maximize the scores or not.
- Returns:
A scalar tensor of the best index.
- Return type:
Tensor
- abstract select(hypotheses: list[str], expected_scores: Tensor, nbest: int = 1, source: str | None = None, maximize: bool = True, **kwargs) Output[source]#
Select the final output list.
- Parameters:
- Returns:
Selected hypotheses.
- Return type:
- superior(a: float, b: float, maximize: bool = True) bool[source]#
Return whether the score a is superior to the score b.