mbrs.decoders.aggregate_mbr module

mbrs.decoders.aggregate_mbr module#

class mbrs.decoders.aggregate_mbr.DecoderAggregateMBR(cfg: ~mbrs.decoders.base.DecoderBase.Config, metric: ~mbrs.metrics.base.MetricBase, selector: ~mbrs.selectors.base.Selector = <mbrs.selectors.nbest.SelectorNbest object>)[source]#

Bases: DecoderMBR

MBR decoding with reference aggregation.

  • Time complexity: O(N)

  • Space complexity: O(N)

References

J. DeNero et al., 2009, “Fast Consensus Decoding over Translation Forests”. https://aclanthology.org/P09-1064/

J. Vamvas and R. Sennrich, 2024, “Linear-time Minimum Bayes Risk Decoding with Reference Aggregation”. https://arxiv.org/abs/2402.04251

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:
  • hypotheses (list[str]) – Hypotheses.

  • references (list[str]) – References.

  • source (str, optional) – A source.

  • nbest (int) – Return the n-best hypotheses.

  • reference_lprobs (Tensor, optional) – Log-probabilities for each reference sample. The shape must be (len(references),). See https://arxiv.org/abs/2311.05263.

Returns:

The n-best hypotheses.

Return type:

DecoderAggregateMBR.Output