File size: 4,294 Bytes
ac198e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""Human-readable names of the MTEB-lite reference models (used by mteb_lite_release.py).

Our models are described by their merge recipe only: which ADIP checkpoint(s) were merged into which base, with
which method and coefficients.
"""
from __future__ import annotations

import glob
import re
from pathlib import Path

import yaml

REPO = Path(__file__).resolve().parents[1]

RELEASES = {"F-lin0.5": "ADIP-QCRI/ADIP-Embedding-v1-0.6B", "V5-ties-d0.1-l0.5": "ADIP-QCRI/ADIP-Embedding-v2-0.6B"}
BASES = {"qwen3-0.6b": "Qwen/Qwen3-Embedding-0.6B", "qwen3-0.6b+norm": "Qwen/Qwen3-Embedding-0.6B + ADIP tokenizer",
         "qwen3-4b": "Qwen/Qwen3-Embedding-4B"}
# merge-grid model aliases -> readable checkpoint names
ALIAS = {"A": "ADIP-v3 (step 6750)", "S3": "ADIP-v3 stage-3", "V2": "ADIP-v2-ft", "P4355": "ADIP-v3 (step 4355)",
         "F": "ADIP-v3 (final)", "P": "ADIP-v3 (pre-rehearsal)", "V": "ADIP-v4", "S": "ADIP-v4 (stage 1)",
         "V5": "ADIP-v5", "S5": "ADIP-v5 (stage 1)"}
# family (internal id prefix) -> readable family name
FAMILY = [("AS3-", "ADIP-v3 (step 6750) + stage-3"), ("AV2-", "ADIP-v3 (step 6750) + ADIP-v2-ft"),
          ("V5-", "ADIP-v5"), ("S5-", "ADIP-v5 (stage 1)"), ("FV-", "ADIP-v3+v4"), ("Vq-", "ADIP-v3+v4"),
          ("F-", "ADIP-v3 (final)"), ("P-", "ADIP-v3 (pre-rehearsal)"), ("A-", "ADIP-v3 (step 6750)"),
          ("W-", "ADIP weighted soup"), ("V-", "ADIP-v4"), ("S-", "ADIP-v4 (stage 1)")]


def _base_name(path: str) -> str:
    if "Qwen3-Embedding-0.6B" in path:
        return "Qwen3-Embedding-0.6B"
    if "adip-v3-final-lin0.5" in path:
        return "ADIP-Embedding-v1-0.6B"
    if "adip-v5-ties-d0.1-l0.5" in path:
        return "ADIP-Embedding-v2-0.6B"
    return Path(path).parent.parent.name


def merge_specs() -> dict:
    """{spec name: (spec, base name)} from the merge grids."""
    out = {}
    for g in sorted(glob.glob(str(REPO / "configs" / "merge" / "*.yaml"))):
        grid = yaml.safe_load(open(g))
        for s in grid.get("specs", []):
            out.setdefault(s["name"], (s, _base_name(grid.get("base", ""))))
    return out


def recipe(spec: dict, base: str) -> str:
    m, lam = spec["method"], spec["lam"]
    how = {"task_arith": f"linear merge λ={lam}", "ties": f"TIES d={spec.get('density')} λ={lam}",
           "dare": f"DARE p={spec.get('drop')} λ={lam}", "dare_ties": f"DARE-TIES p={spec.get('drop')} λ={lam}"}.get(m, m)
    ms = spec["models"]
    if spec.get("weights"):
        what = " + ".join(f"{w}·{ALIAS.get(a, a)}" for a, w in zip(ms, spec["weights"]))
    else:
        what = " + ".join(ALIAS.get(a, a) for a in ms)
    return f"{what}, {how} into {base}"


def family_name(name: str) -> str:
    if name in BASES:
        return "Qwen3-Embedding base"
    for pre, fam in FAMILY:
        if name.startswith(pre):
            return fam
    return name


_HF: dict = {}


def public_hf_ids() -> dict:
    if not _HF:
        for f in sorted(glob.glob(str(REPO / "configs" / "mteb_lite*models*.txt"))):
            for line in Path(f).read_text().splitlines():
                p = line.split()
                if len(p) >= 2 and p[0].startswith("hf:"):
                    _HF.setdefault(p[1], p[0][3:].partition("+")[0])
    return _HF


def describe(name: str) -> dict:
    """{display_name, family, type, recipe}."""
    specs = merge_specs()
    if name in BASES:
        return {"display_name": BASES[name], "family": "Qwen3-Embedding base", "type": "Qwen base", "recipe": ""}
    if name in specs:
        spec, base = specs[name]
        rec = recipe(spec, base)
        if name in RELEASES:
            return {"display_name": RELEASES[name], "family": family_name(name), "type": "ADIP release", "recipe": rec}
        fam = family_name(name)
        disp = rec if rec.startswith(fam + ",") else f"{fam}: {rec}"
        return {"display_name": disp, "family": fam, "type": "ADIP merge", "recipe": rec}
    hf = public_hf_ids().get(name, name)
    return {"display_name": hf, "family": hf, "type": "public", "recipe": ""}


if __name__ == "__main__":
    for n in ["F-lin0.5", "V5-ties-d0.1-l0.5", "A-lin0.5", "AS3-ties-d0.3-l0.5", "W-A0.7-S3-0.3-l0.5", "Vq-lin0.4",
              "V-lin0.7", "qwen3-0.6b+norm", "bge-small-en-v1.5", "LaBSE"]:
        print(n, "->", describe(n))