transZ commited on
Commit
c17c1ab
1 Parent(s): 96aa1b1

SBertCosine instead of BertScore

Browse files
Files changed (1) hide show
  1. test_parascore.py +5 -5
test_parascore.py CHANGED
@@ -98,7 +98,7 @@ class test_parascore(evaluate.Metric):
98
 
99
  def _download_and_prepare(self, dl_manager):
100
  """Optional: download external resources useful to compute the scores"""
101
- self.score = evaluate.load('bertscore')
102
 
103
  def _edit(self, x, y, lang='en'):
104
  if lang == 'zh':
@@ -121,14 +121,14 @@ class test_parascore(evaluate.Metric):
121
  diversity.append(ss)
122
  return diversity
123
 
124
- def _compute(self, predictions, references, model_type='microsoft/deberta-xlarge-mnli', lang='en'):
125
  """Returns the scores"""
126
 
127
- score = self.score.compute(predictions=predictions, references=references, lang=lang, model_type=model_type)
128
- bert_score = [round(v, 2) for v in score['f1']]
129
  diversity = self._diverse(predictions, references, lang)
130
 
131
  score = [s + 0.05 * d for s, d in zip(bert_score, diversity)]
132
  return {
133
  "score": score,
134
- }
 
98
 
99
  def _download_and_prepare(self, dl_manager):
100
  """Optional: download external resources useful to compute the scores"""
101
+ self.sbert_cosine = evaluate.load('transZ/sbert_cosine')
102
 
103
  def _edit(self, x, y, lang='en'):
104
  if lang == 'zh':
 
121
  diversity.append(ss)
122
  return diversity
123
 
124
+ def _compute(self, predictions, references, model_type='sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2', lang='en'):
125
  """Returns the scores"""
126
 
127
+ score = self.sbert_cosine.compute(predictions=predictions, references=references, model_type=model_type)
128
+ sbert_score = [round(v, 2) for v in score['score']]
129
  diversity = self._diverse(predictions, references, lang)
130
 
131
  score = [s + 0.05 * d for s, d in zip(bert_score, diversity)]
132
  return {
133
  "score": score,
134
+ }