Upload results.py
Browse files- results.py +41 -1
results.py
CHANGED
@@ -123,4 +123,44 @@ class MTEBResults(datasets.GeneratorBasedBuilder):
|
|
123 |
name=datasets.Split.TEST,
|
124 |
gen_kwargs={'filepath': downloaded_files}
|
125 |
)
|
126 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
name=datasets.Split.TEST,
|
124 |
gen_kwargs={'filepath': downloaded_files}
|
125 |
)
|
126 |
+
]
|
127 |
+
|
128 |
+
def _generate_examples(self, filepath):
|
129 |
+
"""This function returns the examples in the raw (text) form."""
|
130 |
+
logger.info(f"Generating examples from {filepath}")
|
131 |
+
|
132 |
+
out = []
|
133 |
+
|
134 |
+
for path in filepath:
|
135 |
+
with open(path, encoding="utf-8") as f:
|
136 |
+
res_dict = json.load(f)
|
137 |
+
ds_name = res_dict["mteb_dataset_name"]
|
138 |
+
split = "test"
|
139 |
+
if (ds_name in TRAIN_SPLIT) and ("train" in res_dict):
|
140 |
+
split = "train"
|
141 |
+
elif (ds_name in VALIDATION_SPLIT) and ("validation" in res_dict):
|
142 |
+
split = "validation"
|
143 |
+
elif (ds_name in DEV_SPLIT) and ("dev" in res_dict):
|
144 |
+
split = "dev"
|
145 |
+
elif "test" not in res_dict:
|
146 |
+
print(f"Skipping {ds_name} as split {split} not present.")
|
147 |
+
continue
|
148 |
+
res_dict = res_dict.get(split)
|
149 |
+
is_multilingual = any(x in res_dict for x in EVAL_LANGS)
|
150 |
+
langs = res_dict.keys() if is_multilingual else ["en"]
|
151 |
+
for lang in langs:
|
152 |
+
if lang in SKIP_KEYS: continue
|
153 |
+
test_result_lang = res_dict.get(lang) if is_multilingual else res_dict
|
154 |
+
for metric, score in test_result_lang.items():
|
155 |
+
if not isinstance(score, dict):
|
156 |
+
score = {metric: score}
|
157 |
+
for sub_metric, sub_score in score.items():
|
158 |
+
if any(x in sub_metric for x in SKIP_KEYS): continue
|
159 |
+
out.append({
|
160 |
+
"mteb_dataset_name": ds_name,
|
161 |
+
"eval_language": lang if is_multilingual else "",
|
162 |
+
"metric": f"{metric}_{sub_metric}" if metric != sub_metric else metric,
|
163 |
+
"score": sub_score * 100,
|
164 |
+
})
|
165 |
+
for idx, row in enumerate(sorted(out, key=lambda x: x["mteb_dataset_name"])):
|
166 |
+
yield idx, row
|