Spaces:
Runtime error
Runtime error
Commit
·
edd993d
1
Parent(s):
bac1189
add exact match
Browse files- textgen_evaluator.py +14 -3
textgen_evaluator.py
CHANGED
|
@@ -52,6 +52,8 @@ Scores are calculated for individual translated segments—generally sentences
|
|
| 52 |
Those scores are then averaged over the whole corpus to reach an estimate of the translation's overall quality.
|
| 53 |
Neither intelligibility nor grammatical correctness are not taken into account.
|
| 54 |
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
|
| 57 |
_KWARGS_DESCRIPTION = """
|
|
@@ -76,6 +78,9 @@ BLEU:{
|
|
| 76 |
'length_ratio': ratio of lengths,
|
| 77 |
'translation_length': translation_length,
|
| 78 |
'reference_length': reference_length
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
"""
|
| 81 |
|
|
@@ -104,12 +109,18 @@ class TextGenEvaluator(evaluate.Metric):
|
|
| 104 |
|
| 105 |
rouge_score = evaluate.load("rouge")
|
| 106 |
|
| 107 |
-
|
| 108 |
predictions=predictions, references=references
|
| 109 |
)
|
| 110 |
bleu_score = evaluate.load("bleu")
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
predictions=predictions, references=references
|
| 113 |
)
|
|
|
|
| 114 |
|
| 115 |
-
return {"ROUGE":
|
|
|
|
| 52 |
Those scores are then averaged over the whole corpus to reach an estimate of the translation's overall quality.
|
| 53 |
Neither intelligibility nor grammatical correctness are not taken into account.
|
| 54 |
|
| 55 |
+
EXACT MATCH: Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.
|
| 56 |
+
|
| 57 |
"""
|
| 58 |
|
| 59 |
_KWARGS_DESCRIPTION = """
|
|
|
|
| 78 |
'length_ratio': ratio of lengths,
|
| 79 |
'translation_length': translation_length,
|
| 80 |
'reference_length': reference_length
|
| 81 |
+
},
|
| 82 |
+
EXACT_MATCH:{
|
| 83 |
+
"exact_match": exact_match rate. Possible values are between 0.0 and 1.0, inclusive.
|
| 84 |
}
|
| 85 |
"""
|
| 86 |
|
|
|
|
| 109 |
|
| 110 |
rouge_score = evaluate.load("rouge")
|
| 111 |
|
| 112 |
+
rouge_results = rouge_score.compute(
|
| 113 |
predictions=predictions, references=references
|
| 114 |
)
|
| 115 |
bleu_score = evaluate.load("bleu")
|
| 116 |
+
bleu_results = bleu_score.compute(
|
| 117 |
+
predictions=predictions, references=references
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
exact_match_score = evaluate.load("exact_match")
|
| 121 |
+
exact_match_results = exact_match_score.compute(
|
| 122 |
predictions=predictions, references=references
|
| 123 |
)
|
| 124 |
+
|
| 125 |
|
| 126 |
+
return {"ROUGE": rouge_results, "BLEU": bleu_results, "EXACT_MATCH": exact_match_results}
|