1import pear
23metric = pear.load_metric("pear")# resolves to this Hugging Face model45scores = pear.score_pairwise(6 metric,7 sources=["The cat is on the mat."],8 translations_a=["El gato está en la alfombra."],9 translations_b=["El gato está en el mapa."],10 batch_size=16,11 gpus="auto",12 progress_bar=True,13)
1scores = pear.score_pairwise(2 metric,3 sources=["The cat is on the mat."],4 translations_a=["El gato está en la alfombra."],5 translations_b=["El gato está en el mapa."],6 mode="both",7)8# {"forward": [...], "reverse": [...]}
Reference-anchored PEAR
PEAR can also use a human reference, or any other anchor translation, as the
second candidate:
python
1scores = pear.score_reference_anchored(2 metric,3 sources=["The cat is on the mat."],4 translations=["El gato está en la alfombra."],5 references=["El gato está sobre la alfombra."],6 batch_size=16,7)
As in pairwise QE scoring, mode="both" is available for both-order
reference-anchored inference.
PEAR for MBR decoding
python
1from pear.mbr import pear_utility_matrix, select_mbr_hypothesis
23metric = pear.load_metric("pear")4source ="Questa è una traduzione molto buona."5hypotheses =[6"This is a good translation.",7"This is a very good translation.",8"This is a bad translation.",9]1011utility = pear_utility_matrix(12 metric,13 source,14 hypotheses,15 mode="half",16 batch_size=16,17)18index, expected_utility = select_mbr_hypothesis(utility)19print(hypotheses[index], expected_utility)
Use mode="full" for all off-diagonal ordered pairs, or mode="half" to
score only one triangular half and fill the opposite direction by PEAR
antisymmetry.
CLI examples
Pairwise TSV input must contain src, mt_0, and mt_1 columns:
Use --gpus 0 to force CPU inference. The default, --gpus auto, selects one
available CUDA or MPS accelerator.
Citation
If you use this model, please cite the PEAR paper:
bibtex
1@inproceedings{proietti-etal-2026-pear,
2 title = "{PEAR}: Pairwise Evaluation for Automatic Relative Scoring in Machine Translation",
3 author = "Proietti, Lorenzo and
4 Grundkiewicz, Roman and
5 Post, Matt",
6 editor = "Liakata, Maria and
7 Moreira, Viviane P. and
8 Zhang, Jiajun and
9 Jurgens, David",
10 booktitle = "Proceedings of the 64th Annual Meeting of the {A}ssociation for {C}omputational {L}inguistics (Volume 1: Long Papers)",
11 month = jul,
12 year = "2026",
13 address = "San Diego, California, United States",
14 publisher = "Association for Computational Linguistics",
15 url = "https://aclanthology.org/2026.acl-long.1953/",
16 doi = "10.18653/v1/2026.acl-long.1953",
17 pages = "42189--42207",
18 ISBN = "979-8-89176-390-6"
19}