EuroEval 15.8.0__py3-none-any.whl → 15.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of EuroEval might be problematic. Click here for more details.

euroeval/data_models.py CHANGED
@@ -529,12 +529,16 @@ class DatasetConfig:
529
529
  else:
530
530
  sep_word = main_language.or_separator
531
531
 
532
+ local_labels: list[str] = []
533
+ for label in self.labels:
534
+ if label not in self.prompt_label_mapping:
535
+ continue
536
+ local_label = self.prompt_label_mapping[label]
537
+ if local_label not in local_labels:
538
+ local_labels.append(local_label)
539
+
532
540
  # Convert labels to single-quoted labels - and remove duplicates
533
- quoted_labels = [
534
- f"'{self.prompt_label_mapping[label]}'"
535
- for label in set(self.labels)
536
- if label in self.prompt_label_mapping
537
- ]
541
+ quoted_labels = [f"'{label}'" for label in local_labels]
538
542
 
539
543
  if not quoted_labels:
540
544
  return ""
@@ -144,9 +144,27 @@ def extract_labels_from_generation(
144
144
  )
145
145
  if labels is not None:
146
146
  return labels
147
- return get_closest_word_edit_labels(
148
- generated_sequences=model_output.sequences, dataset_config=dataset_config
149
- )
147
+
148
+ candidate_labels = [
149
+ dataset_config.prompt_label_mapping[lbl]
150
+ for lbl in dataset_config.id2label.values()
151
+ ]
152
+ new_predicted_labels: list[str] = list()
153
+ for predicted_label in model_output.sequences:
154
+ # If the prediction includes a boxed answer, use that instead of the full
155
+ # generation
156
+ if (m := re.search(r"boxed\{(.*?)\}", predicted_label)) is not None:
157
+ predicted_label = m.group(1)
158
+
159
+ # Pick the label with the smallest word edit distance to the predicted label
160
+ edit_distances = [
161
+ Levenshtein.distance(s1=predicted_label.lower(), s2=candidate_label.lower())
162
+ for candidate_label in candidate_labels
163
+ ]
164
+ predicted_label = candidate_labels[np.argmin(edit_distances).item()]
165
+ new_predicted_labels.append(predicted_label)
166
+
167
+ return new_predicted_labels
150
168
 
151
169
 
152
170
  def get_closest_logprobs_labels(
@@ -305,32 +323,3 @@ def get_closest_logprobs_labels(
305
323
 
306
324
  assert len(output_labels) == len(generation_logprobs)
307
325
  return output_labels
308
-
309
-
310
- def get_closest_word_edit_labels(
311
- generated_sequences: list[str], dataset_config: "DatasetConfig"
312
- ) -> list[str]:
313
- """Get the labels with the smallest edit distance to the predicted labels.
314
-
315
- Args:
316
- generated_sequences:
317
- The generated sequences from the model.
318
- dataset_config:
319
- The configuration of the dataset.
320
-
321
- Returns:
322
- The candidate labels with the smallest edit distance to the predicted labels.
323
- """
324
- candidate_labels = [
325
- dataset_config.prompt_label_mapping[lbl]
326
- for lbl in dataset_config.id2label.values()
327
- ]
328
- new_predicted_labels: list[str] = list()
329
- for predicted_label in generated_sequences:
330
- edit_distances = [
331
- Levenshtein.distance(s1=predicted_label.lower(), s2=candidate_label.lower())
332
- for candidate_label in candidate_labels
333
- ]
334
- closest_label = candidate_labels[np.argmin(edit_distances).item()]
335
- new_predicted_labels.append(closest_label)
336
- return new_predicted_labels
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: EuroEval
3
- Version: 15.8.0
3
+ Version: 15.8.1
4
4
  Summary: The robust European language model benchmark.
5
5
  Project-URL: Repository, https://github.com/EuroEval/EuroEval
6
6
  Project-URL: Issues, https://github.com/EuroEval/EuroEval/issues
@@ -5,7 +5,7 @@ euroeval/callbacks.py,sha256=F1AJCLB8FJpxqYprwLi_PsH4Bc0x4lyR8UiTG-GlFLY,2452
5
5
  euroeval/cli.py,sha256=EMB6g6kRvxIqlfYLSoMzwLAtEd-fqXipo4A_HTkhjkA,8575
6
6
  euroeval/constants.py,sha256=p6kp_R6-Tq5LBvyXyT6Sa6N3SkjEElGS2LSZRBoQaYs,1985
7
7
  euroeval/data_loading.py,sha256=L_REtxefte5Ke4xE_Cz01zkfCyKlOYhSqT5ZXXulHPc,3992
8
- euroeval/data_models.py,sha256=t5FwpGxiSIMe7iKae-tT7usUWki-ILzAFFm7dPJoFsk,22973
8
+ euroeval/data_models.py,sha256=59ca6gxmHwMdeIIU6f-gGXOVIXXDQPOt7m5nCXHK86E,23166
9
9
  euroeval/enums.py,sha256=L9LcNeruuhHvze9vKRogXY9vonRzoBqDzWSP6hxKQ7A,3195
10
10
  euroeval/exceptions.py,sha256=LRd7HoudupRp5-AX3L0X4hIAWCa6JVx-LViHPg7u7dg,5821
11
11
  euroeval/finetuning.py,sha256=uuaUxNQJb7TivPQuI1OYQ_MIKbD-6-7mpkobLKsDefQ,10667
@@ -51,11 +51,11 @@ euroeval/prompt_templates/summarization.py,sha256=mcWeKNhGWmp7IG_iY64T-VOSabQg5w
51
51
  euroeval/task_group_utils/__init__.py,sha256=CorGVkixkoEDOQuDsrOGlTmF1zmM0wnGHs8psWTfD28,72
52
52
  euroeval/task_group_utils/multiple_choice_classification.py,sha256=nB78TzOgd0HBvTclmjOYJid9ZVAgu8IHZsqB_n1SAZU,6178
53
53
  euroeval/task_group_utils/question_answering.py,sha256=kZBABJ_WYNTH4Xgo2jIvfx7iYvfoGt0EUObSaXRCGmk,27700
54
- euroeval/task_group_utils/sequence_classification.py,sha256=MCdO5h3v_LWTkrvKAeefPq7rl1H5mFed50nAL4uZq0E,13837
54
+ euroeval/task_group_utils/sequence_classification.py,sha256=Yqx0pUhuHYmSkv1ZUfOndSLTvpr0lWCk19oYITfSjV4,13555
55
55
  euroeval/task_group_utils/text_to_text.py,sha256=Nu1_qRPLbboCd9Q5rxqY4fQFJ_aGXu80aWQqoTG1cYc,5047
56
56
  euroeval/task_group_utils/token_classification.py,sha256=3idWB81Fcx9UhTuk-gxMfXENrCBmiWBDUWdULXoIhpw,17863
57
- euroeval-15.8.0.dist-info/METADATA,sha256=-GcGBuEnlAPmpT9ItDAmS0psT__jwbVoNkTYOiSeRzA,13669
58
- euroeval-15.8.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
59
- euroeval-15.8.0.dist-info/entry_points.txt,sha256=tKQRxN0HX2mGtbZbZQdCRFUDZIecA_z4mZduueor3Ug,135
60
- euroeval-15.8.0.dist-info/licenses/LICENSE,sha256=oZp5fpOSQ7w-vFui8QNwrBIosrO7cnpArItdbvn52Ao,1082
61
- euroeval-15.8.0.dist-info/RECORD,,
57
+ euroeval-15.8.1.dist-info/METADATA,sha256=Fdzj20PR6wWZUx_7f_bhPh8S4DF6ghZwMIDrJ4ozxFE,13669
58
+ euroeval-15.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
59
+ euroeval-15.8.1.dist-info/entry_points.txt,sha256=tKQRxN0HX2mGtbZbZQdCRFUDZIecA_z4mZduueor3Ug,135
60
+ euroeval-15.8.1.dist-info/licenses/LICENSE,sha256=oZp5fpOSQ7w-vFui8QNwrBIosrO7cnpArItdbvn52Ao,1082
61
+ euroeval-15.8.1.dist-info/RECORD,,