Datasets:
mteb
/

File size: 2,209 Bytes
1cc8a8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import os

REPLACE_MAP = {
    "NDCG": 'ndcg',
    "MAP": 'map',
    "MRR": 'mrr',
    "RECALL": 'recall',
    "P": 'precision',
}

MODEL_TO_MODEL = {
    "bm25": "bm25",
    "bge": "bge-large-en-v1.5",
    "cohere": "Cohere-embed-english-v3.0",
    "e5": "e5-mistral-7b-instruct",
    "google": "google-gecko.text-embedding-preview-0409",
    "grit": "GritLM-7B",
    "inst-l": "instructor-large",
    "inst-xl": "instructor-xl",
    "openai": "text-embedding-3-large",
    "qwen2": "gte-Qwen2-7B-instruct",
    "qwen": "gte-Qwen1.5-7B-instruct",
    "sbert": "all-mpnet-base-v2",
    "sf": "SFR-Embedding-Mistral",
    "voyage": "voyage-large-2-instruct",
}
folders = os.listdir('bright_scores')
print(folders)
models = set([x.split("_")[-3] for x in folders if os.path.isdir('bright_scores/' + x)])
for model in models:
    print(f"Converting {model}")
    result_template = {
        "dataset_revision": "a75a0eb",
        "mteb_version": "1.12.79",
        "scores": {
            "standard": []
        },
        "task_name": "BrightRetrieval",
    }
    for folder in [x for x in folders if (os.path.isdir('bright_scores/' + x)) and (x.split("_")[-3] == model)]:
        results_path = 'bright_scores/' + folder + '/results.json'
        if len(folder.split("_")) == 4:
            split = folder.split("_")[0]
        elif len(folder.split("_")) == 5:
            split = folder.split("_")[0] + "_" + folder.split("_")[1]
        with open(results_path) as f:
            results = json.load(f)
        result_template['scores']['standard'].append(
            {
                "hf_subset": split,
                "languages": ["eng-Latn"],
                "main_score": results["NDCG@10"],
                **{"_at_".join([REPLACE_MAP.get(x, x) for x in k.split("@")]): v for k,v in results.items()}
            }
        )
    
    model_folder = MODEL_TO_MODEL[model]
    os.makedirs(f"results/{model_folder}/no_revision_available", exist_ok=True)
    print(f"Writing to: results/{model_folder}/no_revision_available/BrightRetrieval.json")
    with open(f"results/{model_folder}/no_revision_available/BrightRetrieval.json", "w") as f:
        json.dump(result_template, f, indent=4)