File size: 2,846 Bytes
1cc8a8e 11a9906 1cc8a8e 11a9906 9355679 1cc8a8e ef44d4f 11a9906 1cc8a8e 9355679 11a9906 9355679 11a9906 9355679 11a9906 9355679 1cc8a8e 9355679 11a9906 1cc8a8e 9355679 1cc8a8e 11a9906 1cc8a8e 11a9906 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
import json
import os
REPLACE_MAP = {
"NDCG": "ndcg",
"MAP": "map",
"MRR": "mrr",
"RECALL": "recall",
"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/main") + os.listdir("bright_scores/long_context")
models = set(
[
x.split("_")[-3]
for x in folders
if (os.path.isdir("bright_scores/main/" + x) or os.path.isdir("bright_scores/long_context/" + x))
]
)
print(models)
for model in models:
print(f"Converting {model}")
result_template = {
"dataset_revision": "a75a0eb483f6a5233a6efc2d63d71540a4443dfb",
"evaluation_time": 0,
"kg_co2_emissions": None,
"mteb_version": "1.12.79",
"scores": {"standard": [], "long": []},
"task_name": "BrightRetrieval",
}
for folder in [
x
for x in folders
if (os.path.isdir("bright_scores/main/" + x) or os.path.isdir("bright_scores/long_context/" + x))
and (x.split("_")[-3] == model)
]:
if os.path.isdir("bright_scores/main/" + folder):
results_path = os.path.join("bright_scores/main", folder, "results.json")
split = "standard"
else:
results_path = os.path.join("bright_scores/long_context", folder, "results.json")
assert "long_True" in folder, folder
split = "long"
with open(results_path) as f:
results = json.load(f)
if len(folder.split("_")) == 4:
subset = folder.split("_")[0]
elif len(folder.split("_")) == 5:
subset = folder.split("_")[0] + "_" + folder.split("_")[1]
result_template["scores"][split].append(
{
"hf_subset": subset,
"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)
|