TheAnsIs42 commited on
Commit
3853a8e
β€’
1 Parent(s): 4ad1e3f

change filename, parse results

Browse files

Former-commit-id: 6686e2a3ddcb1ba2871be6a1786c262af1a852ba

evaluation/scores/{multi_score.py β†’ multi_scores.py} RENAMED
@@ -2,15 +2,15 @@ from comet import download_model, load_from_checkpoint
2
  from sacrebleu.metrics import BLEU, CHRF, TER
3
  import LLM_eval
4
 
5
- class multi_score:
6
  def __init__(self) -> None:
7
  self.comet_model = load_from_checkpoint(download_model("Unbabel/wmt22-comet-da"))
8
  self.bleu_model = BLEU()
9
  self.LLM_model = LLM_eval.init_evaluator()
10
 
11
- def get(self, src, mt, ref):
12
- comet_score = self.comet_model.predict([{"src":src, "mt":mt, "ref":ref}], batch_size=8, gpus=0).scores
13
  bleu_score = self.bleu_model.corpus_score(mt, ref).score
14
- LLM_score = LLM_eval.evaluate_prediction(src, ref, mt, self.LLM_model)
15
  return {'bleu':bleu_score, 'comet':comet_score, 'llm':LLM_score}
16
 
 
2
  from sacrebleu.metrics import BLEU, CHRF, TER
3
  import LLM_eval
4
 
5
+ class multi_scores:
6
  def __init__(self) -> None:
7
  self.comet_model = load_from_checkpoint(download_model("Unbabel/wmt22-comet-da"))
8
  self.bleu_model = BLEU()
9
  self.LLM_model = LLM_eval.init_evaluator()
10
 
11
+ def get(self, src:str, mt:str, ref:str) -> dict:
12
+ comet_score = self.comet_model.predict([{"src":src, "mt":mt, "ref":ref}], batch_size=8, gpus=0).scores[0]
13
  bleu_score = self.bleu_model.corpus_score(mt, ref).score
14
+ LLM_score = LLM_eval.evaluate_prediction(src, ref, mt, self.LLM_model).score
15
  return {'bleu':bleu_score, 'comet':comet_score, 'llm':LLM_score}
16
 
evaluation/scores/{scores.py β†’ score.py} RENAMED
@@ -2,7 +2,9 @@ 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=0)
 
2
  from sacrebleu.metrics import BLEU, CHRF, TER
3
 
4
  def COMETscore(src, mt, ref):
5
+ data = []
6
+ for i in enumerate(src):
7
+ data.append({"src":src[i], "mt":mt[i], "ref":ref[i]})
8
  model_path = download_model("Unbabel/wmt22-comet-da")
9
  model = load_from_checkpoint(model_path)
10
  model_output = model.predict(data, batch_size = 8, gpus=0)