mbrs.metrics.chrf module#
- class mbrs.metrics.chrf.MetricChrF(cfg: Config)[source]#
Bases:
MetricAggregatableChrF metric class.
- class AggregatedReference(ngrams: list[Counter])[source]#
Bases:
objectAggregated reference representation.
ngrams (list[Counter]]): Bags of n-grams for each order.
- class Config(char_order: int = 6, word_order: int = 0, beta: int = 2, lowercase: bool = False, whitespace: bool = False, eps_smoothing: bool = False, num_workers: int = 8, fastchrf: bool = False)[source]#
Bases:
ConfigChrF metric configuration.
char_order (int): Character n-gram order.
word_order (int): Word n-gram order. If equals to 2, the metric is referred to as chrF++.
beta (int): Determine the importance of recall w.r.t precision.
lowercase (bool): Enable case-insensitivity.
whitespace (bool): If True, include whitespaces when extracting character n-grams.
- eps_smoothing (bool): If True, applies epsilon smoothing similar to reference chrF++.py, NLTK and Moses implementations.
Otherwise, it takes into account effective match order similar to sacreBLEU < 2.0.0.
num_workers (int): Number of workers for multiprocessing.
fastchrf (bool): Use the rust implementation of chrF.
- corpus_score(hypotheses: list[str], references_lists: list[list[str]], sources: list[str] | None = None) float[source]#
Calculate the corpus-level score.
- expected_scores_reference_aggregation(hypotheses: list[str], references: list[str], source: str | None = None, reference_lprobs: Tensor | None = None) Tensor[source]#
Calculate the expected scores for each hypothesis.
- Parameters:
- Returns:
The expected scores for each hypothesis.
- Return type:
Tensor
- pairwise_scores(hypotheses: list[str], references: list[str], *_, **__) Tensor[source]#
Calculate the pairwise scores.