MCPcopy Create free account
hub / github.com/InternScience/InternAgent / calculate_bert_scores

Function calculate_bert_scores

tasks/AutoMem/code/utils.py:68–83  ·  view source on GitHub ↗

Calculate BERTScore for semantic similarity.

(prediction: str, reference: str)

Source from the content-addressed store, hash-verified

66 return scores
67
68def calculate_bert_scores(prediction: str, reference: str) -> Dict[str, float]:
69 """Calculate BERTScore for semantic similarity."""
70 try:
71 P, R, F1 = bert_score([prediction], [reference], lang='en', verbose=False)
72 return {
73 'bert_precision': P.item(),
74 'bert_recall': R.item(),
75 'bert_f1': F1.item()
76 }
77 except Exception as e:
78 print(f"Error calculating BERTScore: {e}")
79 return {
80 'bert_precision': 0.0,
81 'bert_recall': 0.0,
82 'bert_f1': 0.0
83 }
84
85def calculate_meteor_score(prediction: str, reference: str) -> float:
86 """Calculate METEOR score for the prediction."""

Callers 1

calculate_metricsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected