Realm

oa::ml::metric::bleu

Corpus BLEU over token sequences with a brevity penalty, no smoothing. Counts clipped n-gram matches up to max_order across the corpus and combines them geometrically. A corpus with no matches at any order returns 0.0; hypotheses shorter than references receive the standard exp(1 - ref/hyp) penalty. Inputs are host token sequences — this is an evaluation-side metric, not a device op. Errors Returns an error when max_order is zero, the corpora differ in length, a hypothesis is empty, or any sequence is shorter than max_order.

FnRust public API

Function Documentation

pub fn bleu( references: &[Vec<u32>], hypotheses: &[Vec<u32>], max_order: usize ) -> Result<f32>
Corpus BLEU over token sequences with a brevity penalty, no smoothing. Counts clipped n-gram matches up to max_order across the corpus and combines them geometrically. A corpus with no matches at any order returns 0.0; hypotheses shorter than references receive the standard exp(1 - ref/hyp) penalty. Inputs are host token sequences — this is an evaluation-side metric, not a device op. Errors Returns an error when max_order is zero, the corpora differ in length, a hypothesis is empty, or any sequence is shorter than max_order.