Upload results.py
Browse files- results.py +92 -0
results.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""MTEB Results"""
|
2 |
+
|
3 |
+
import json
|
4 |
+
|
5 |
+
import datasets
|
6 |
+
|
7 |
+
|
8 |
+
logger = datasets.logging.get_logger(__name__)
|
9 |
+
|
10 |
+
|
11 |
+
_CITATION = """@article{muennighoff2022mteb,
|
12 |
+
doi = {10.48550/ARXIV.2210.07316},
|
13 |
+
url = {https://arxiv.org/abs/2210.07316},
|
14 |
+
author = {Muennighoff, Niklas and Tazi, Nouamane and Magne, Lo{\"\i}c and Reimers, Nils},
|
15 |
+
title = {MTEB: Massive Text Embedding Benchmark},
|
16 |
+
publisher = {arXiv},
|
17 |
+
journal={arXiv preprint arXiv:2210.07316},
|
18 |
+
year = {2022}
|
19 |
+
}
|
20 |
+
"""
|
21 |
+
|
22 |
+
_DESCRIPTION = """Results on MTEB Portuguese"""
|
23 |
+
|
24 |
+
URL = "https://huggingface.co/datasets/mteb/results/resolve/main/paths.json"
|
25 |
+
VERSION = datasets.Version("1.0.1")
|
26 |
+
EVAL_LANGS = ['pt']
|
27 |
+
|
28 |
+
SKIP_KEYS = ["std", "evaluation_time", "main_score", "threshold"]
|
29 |
+
|
30 |
+
|
31 |
+
MODELS = [
|
32 |
+
"multilingual-e5-base"
|
33 |
+
]
|
34 |
+
|
35 |
+
|
36 |
+
# Needs to be run whenever new files are added
|
37 |
+
def get_paths():
|
38 |
+
import collections, json, os
|
39 |
+
files = collections.defaultdict(list)
|
40 |
+
for model_dir in os.listdir("results"):
|
41 |
+
results_model_dir = os.path.join("results", model_dir)
|
42 |
+
if not os.path.isdir(results_model_dir):
|
43 |
+
print(f"Skipping {results_model_dir}")
|
44 |
+
continue
|
45 |
+
for res_file in os.listdir(results_model_dir):
|
46 |
+
if res_file.endswith(".json"):
|
47 |
+
results_model_file = os.path.join(results_model_dir, res_file)
|
48 |
+
files[model_dir].append(results_model_file)
|
49 |
+
with open("paths.json", "w") as f:
|
50 |
+
json.dump(files, f)
|
51 |
+
return files
|
52 |
+
|
53 |
+
|
54 |
+
class MTEBResults(datasets.GeneratorBasedBuilder):
|
55 |
+
"""MTEBResults"""
|
56 |
+
|
57 |
+
BUILDER_CONFIGS = [
|
58 |
+
datasets.BuilderConfig(
|
59 |
+
name=model,
|
60 |
+
description=f"{model} MTEB results",
|
61 |
+
version=VERSION,
|
62 |
+
)
|
63 |
+
for model in MODELS
|
64 |
+
]
|
65 |
+
|
66 |
+
def _info(self):
|
67 |
+
return datasets.DatasetInfo(
|
68 |
+
description=_DESCRIPTION,
|
69 |
+
features=datasets.Features(
|
70 |
+
{
|
71 |
+
"mteb_dataset_name": datasets.Value("string"),
|
72 |
+
"eval_language": datasets.Value("string"),
|
73 |
+
"metric": datasets.Value("string"),
|
74 |
+
"score": datasets.Value("float"),
|
75 |
+
}
|
76 |
+
),
|
77 |
+
supervised_keys=None,
|
78 |
+
citation=_CITATION,
|
79 |
+
)
|
80 |
+
|
81 |
+
def _split_generators(self, dl_manager):
|
82 |
+
path_file = dl_manager.download_and_extract(URL)
|
83 |
+
with open(path_file) as f:
|
84 |
+
files = json.load(f)
|
85 |
+
|
86 |
+
downloaded_files = dl_manager.download_and_extract(files[self.config.name])
|
87 |
+
return [
|
88 |
+
datasets.SplitGenerator(
|
89 |
+
name=datasets.Split.TEST,
|
90 |
+
gen_kwargs={'filepath': downloaded_files}
|
91 |
+
)
|
92 |
+
]
|