mbrs: A Library for Minimum Bayes Risk Decoding

Hiroyuki Deguchi, Yusuke Sakai, Hidetaka Kamigaito, Taro Watanabe

Abstract

Minimum Bayes Risk (MBR) decoding has emerged as a powerful alternative to standard Maximum A Posteriori (MAP) decoding, often overcoming the "beam search curse" to produce higher-quality text. However, the lack of a unified implementation has made it difficult to compare different MBR variants and metrics systematically. We introduce MBRS, an open-source Python/PyTorch library that standardizes the MBR workflow. MBRS supports a wide range of decoders, metrics, and estimation methods, alongside profiling tools to identify computational bottlenecks. Experiments on WMT’22 translation tasks show that MBRS-implemented decoders significantly outperform beam search in quality while offering efficient variants that are up to 26 times faster than vanilla MBR.

Introduction

In modern Natural Language Processing, text generation typically relies on MAP decoding, often implemented via beam search. While efficient, MAP decoding is prone to generating repetitive or pathologically short sequences as the search space grows. MBR decoding addresses this by selecting the hypothesis that maximizes expected utility (e.g., BLEU, COMET) across a set of pseudo-references, rather than simply picking the most probable sequence. Despite its advantages, MBR is computationally intensive and has historically lacked a common, interoperable library.

The MBRS Framework

MBRS provides a modular architecture that separates the core components of the MBR process: metric calculation, estimation, and decoding logic. This design allows researchers to mix and match different strategies easily.

The MBRS workflow separates the Metric calculation from the Decoder logic, allowing for flexible combinations of algorithms and evaluation metrics.

Key technical features of the library include:

  • Diverse Decoders: Beyond vanilla MBR, the library includes efficient variants such as RAMBR (Reference Aggregation), CBMBR (Centroid-based), and PruneMBR (Confidence-based pruning).
  • Extensive Metric Support: Support for traditional metrics (BLEU, CHRF) and modern neural metrics (COMET, BLEURT).
  • Estimation Flexibility: Users can choose between standard Monte Carlo (MC) and newer model-based (MB) estimation.
  • Profiling Tools: A built-in code block profiler helps developers measure execution time and call counts for specific functions, facilitating optimization.

Experimental Setup

The library was benchmarked using the WMT’22 general translation tasks across several language pairs, including English ↔ German, English ↔ Chinese, and English ↔ Japanese. Candidates were generated using the M2M100 model, with 1,024 samples per input serving as both the hypothesis set and the pseudo-reference set.

Insights and Performance

Quality vs. Probability

A key insight reinforced by MBRS is that high-quality outputs are often not the most probable ones according to the model. MBR decoding frequently selects hypotheses with relatively low probability ranks but high utility scores.

The empirical cumulative distribution shows that MBR decoding often selects hypotheses with lower probability ranks, highlighting the gap between model probability and human-perceived quality.

Performance Gains

Experimental results show substantial quality improvements. In the En-De task, MBR using the COMET metric achieved a score of 83.9, compared to 77.3 for standard MAP beam search. Furthermore, efficient variants like RAMBR drastically reduce the computational overhead. For instance, RAMBR with BLEU utility was found to be nearly 26 times faster than vanilla MBR in end-to-end execution time (605.6ms vs. 16076.0ms).

Conclusion

MBRS fills a critical gap in the NLP ecosystem by providing a unified, extensible library for MBR decoding. By standardizing implementations and providing transparency through profiling, MBRS enables researchers to develop and compare high-quality decoding strategies more effectively. The library is available as an open-source project under the MIT license.

Summary updated

BibTeX
@inproceedings{deguchi2024mbrs,
  author = {Hiroyuki Deguchi and Yusuke Sakai and Hidetaka Kamigaito and Taro Watanabe},
  title = {{mbrs: A Library for Minimum Bayes Risk Decoding}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=MyqvIsYLmy},
}
Figure