mbrs.metrics.bleurt module#
- class mbrs.metrics.bleurt.MetricBLEURT(cfg: Config)[source]#
Bases:
MetricBLEURT metric class.
We employ the PyTorch port version to implement this metric instead of the original version: lucadiliello/bleurt-pytorch (thanks to @lucadiliello)
Available checkpoints:
lucadiliello/BLEURT-20
lucadiliello/BLEURT-20-D12
lucadiliello/BLEURT-20-D3
lucadiliello/BLEURT-20-D6
lucadiliello/bleurt-base-128
lucadiliello/bleurt-base-512
lucadiliello/bleurt-large-128
lucadiliello/bleurt-large-512
lucadiliello/bleurt-tiny-128
lucadiliello/bleurt-tiny-512
- class Config(model: str = 'lucadiliello/BLEURT-20-D12', batch_size: int = 64, fp16: bool = False, bf16: bool = False, cpu: bool = False)[source]#
Bases:
ConfigBLEURT metric configuration.
model (str): Model name or path.
batch_size (int): Batch size.
fp16 (bool): Use float16 for the forward computation.
bf16 (bool): Use bfloat16 for the forward computation.
cpu (bool): Use CPU for the forward computation.
- corpus_score(hypotheses: list[str], references_lists: list[list[str]], sources: list[str] | None = None) float[source]#
Calculate the corpus-level score.
- property device: device#
Returns the device of the model.
- pairwise_scores(hypotheses: list[str], references: list[str], *_, **__) Tensor[source]#
Calculate the pairwise scores.
- score(hypothesis: str, reference: str, *_, **__) float[source]#
Calculate the score of the given hypothesis.
- scorer: BleurtForSequenceClassification#