Spaces:
Running
Running
DWizard
commited on
Commit
•
0fca289
1
Parent(s):
eb2a612
add BLEU&comet
Browse filesFormer-commit-id: 8d3f934c77c728e3cff19093962e705b501806d1
- evaluation/scores/scores.py +13 -0
evaluation/scores/scores.py
CHANGED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from comet import download_model, load_from_checkpoint
|
2 |
+
from sacrebleu.metrics import BLEU, CHRF, TER
|
3 |
+
|
4 |
+
def COMETscore(src, mt, ref):
|
5 |
+
data = [{"src":src, "mt":mt, "ref":ref}]
|
6 |
+
model_path = download_model("Unbabel/wmt22-comet-da")
|
7 |
+
model = load_from_checkpoint(model_path)
|
8 |
+
model_output = model.predict(data, batch_size = 8, gpus=1)
|
9 |
+
return model_output
|
10 |
+
|
11 |
+
def BLEUscore(sys, refs):
|
12 |
+
bleu = BLEU()
|
13 |
+
return bleu.corpus_score(sys, refs)
|