mbrs.decoders.probabilistic_mbr module#
- class mbrs.decoders.probabilistic_mbr.DecoderProbabilisticMBR(cfg: ~mbrs.decoders.base.DecoderBase.Config, metric: ~mbrs.metrics.base.MetricBase, selector: ~mbrs.selectors.base.Selector = <mbrs.selectors.nbest.SelectorNbest object>)[source]#
Bases:
DecoderMBRProbabilistic MBR decoder using alternating least squares (ALS) approximation.
References
F. Trabelsi et al., 2024, “Efficient Minimum Bayes Risk Decoding using Low-Rank Matrix Completion Algorithms”. https://arxiv.org/abs/2406.02832
- class Config(reduction_factor: float = 8.0, regularization_weight: float = 0.1, rank: int = 8, niter: int = 10, seed: int = 0)[source]#
Bases:
ConfigConfiguration for the decoder.
reduction_factor (float): Reduction factor. The computational budget will be reduced to 1 / reduction_factor.
regularization_weight (float): Weight of L2 regularization.
rank (int): Rank of the factarized matrices.
niter (int): The number of alternating steps performed.
seed (int): Random seed.
- decode(hypotheses: list[str], references: list[str], source: str | None = None, nbest: int = 1, reference_lprobs: Tensor | None = None) Output[source]#
Select the n-best hypotheses based on the strategy.
- Parameters:
- Returns:
The n-best hypotheses.
- Return type:
DecoderMBR.Output