From 1209e32928860029189cd6c667982cf1ad585d0a Mon Sep 17 00:00:00 2001 From: ShirApp <58909189+ShirApp@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:53:32 +0300 Subject: [PATCH] allow multiple references for f1 strings metric (#1225) allow multiple refs Co-authored-by: Elron Bandel --- src/unitxt/metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unitxt/metrics.py b/src/unitxt/metrics.py index bf4448fc6..b8910d3e7 100644 --- a/src/unitxt/metrics.py +++ b/src/unitxt/metrics.py @@ -4741,7 +4741,7 @@ class F1Strings(InstanceMetric): main_score = "f1_strings" reduction_map = {"mean": ["f1_strings"]} prediction_type = str - single_reference_per_prediction = True + single_reference_per_prediction = False _requirements_list = { "spacy": "Please pip install spacy", } @@ -4764,7 +4764,7 @@ def compute( prediction: str, task_data: List[Dict], ) -> dict: - doc_ref = self.nlp(references[0]) + doc_ref = self.nlp(" ".join(references)) set_ref = Counter([token.text.lower() for token in doc_ref]) doc_pred = self.nlp(prediction) set_pred = Counter([token.text.lower() for token in doc_pred])