gpt-code-clippy/metrics/extrinsic_eval.py

18 lines
780 B
Python
Raw Permalink Normal View History

from metrics.bleu import compute_bleu
def compute_metrics(references,generated) -> dict:
"""
Calculates various metrics and returns the calculated dict of these matrics.
args:
reference: list of lists of references for each translation. Each
reference should be tokenized into a list of tokens.
translation: list of translations to score. Each translation
should be tokenized into a list of tokens.
returns:
A dicitonary with different metrics intact.
"""
metrics_dict = {} #Update as in new metrics are added over here.
2021-07-04 07:14:45 +03:00
metrics_dict["smoothed_bleu_4"] = compute_bleu(references,generated,smooth=True)
metrics_dict["bleu_4"] = compute_bleu(references,generated,smooth=False)
return metrics_dict