tomaarsen's picture
download
raw
3.01 kB
# /// script
# requires-python = ">=3.12"
# dependencies = ["matplotlib==3.10.8"]
# ///
"""Plot retrieval scores against backbone parameter counts."""
from __future__ import annotations
import json
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
OUTPUT = Path(__file__).resolve().parent / "plots"
def main():
data = json.loads((OUTPUT / "plot_data.json").read_text())
scores = {(r["model"], r["task"]): r["ndcg@10"] for r in data["results"]}
architectures = [
("ModernBERT", "tab:blue", [(150, "modernbert-base"), (395, "modernbert-large")]),
("Ettin", "tab:green", [(150, "ettin-encoder-150m"), (400, "ettin-encoder-400m")]),
("UltraBERT", "tab:orange", [(150, "ultrabert-150m"), (380, "ultrabert-380m")]),
]
recipes = [("dense", "Dense", "o"), ("multivector", "Multi-Vector", "s"), ("reranker", "Reranker", "^")]
plt.rcParams.update({"font.size": 11, "svg.fonttype": "none", "pdf.fonttype": 42})
fig, ax = plt.subplots(figsize=(10, 6))
for _, color, models in architectures:
for task, _, marker in recipes:
x = [size for size, _ in models]
y = [scores[model, task] for _, model in models]
ax.plot(x, y, color=color, linewidth=1.3, alpha=0.65, zorder=2)
ax.scatter(
x,
y,
marker=marker,
s=90 if marker == "^" else 70,
facecolors="white" if marker == "^" else color,
edgecolors=color,
linewidths=1.7,
zorder=4 if marker == "^" else 3,
)
ax.set_title("Encoder comparison after matched fine-tuning", pad=14)
ax.set_xlabel("Backbone parameters (millions)")
ax.set_ylabel("Mean nDCG@10 (NanoNQ, NanoFiQA2018, NanoSciFact)")
ax.set_xlim(130, 420)
ax.set_ylim(0.48, 0.70)
ax.set_xticks([150, 200, 250, 300, 350, 400])
architecture_legend = ax.legend(
handles=[Line2D([0], [0], color=color, linewidth=2, label=name) for name, color, _ in architectures],
title="Architecture",
loc="upper left",
frameon=False,
)
ax.add_artist(architecture_legend)
ax.legend(
handles=[
Line2D(
[0],
[0],
linestyle="none",
marker=marker,
color="0.3",
markerfacecolor="white" if marker == "^" else "0.3",
markersize=8,
label=label,
)
for _, label, marker in recipes
],
title="Recipe",
loc="upper left",
bbox_to_anchor=(0.28, 1),
frameon=False,
)
fig.tight_layout()
for extension in ("png", "svg", "pdf"):
path = OUTPUT / f"encoder_comparison_sizes.{extension}"
fig.savefig(path, dpi=200, facecolor="white")
print(path)
plt.close(fig)
if __name__ == "__main__":
main()

Xet Storage Details

Size:
3.01 kB
·
Xet hash:
7bf429646ccc3ffbf7b54ff06ee4c77f4eda25b26efaa30602a26d36d69ed624

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.