Buckets:
| """Extra figures for the README: a header banner and a pair-by-pair grid. | |
| Usage: python make_figures.py (reads outputs_labeled.csv in the current folder) | |
| """ | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| from matplotlib.patches import FancyBboxPatch | |
| COLORS = {"correct": "#2b7bba", "wrong": "#f0a030", "invented": "#d0342c", "abstain": "#9a9a9a"} | |
| INK = "#1f2328" | |
| MUTED = "#57606a" | |
| BG = "#ffffff" | |
| SHORT = { | |
| "p01": ("zem", "Vélib'"), | |
| "p02": ("atassi", "aligot"), | |
| "p03": ("vouadzou", "raclette"), | |
| "p04": ("wô", "far breton"), | |
| "p05": ("CEP", "brevet"), | |
| "p06": ("BEPC", "CAP"), | |
| "p07": ("« doucement »", "« ça caille »"), | |
| "p08": ("« tu vas lire l'heure »", "« poser un lapin »"), | |
| "p09": ("langue de Cotonou", "langue de Bretagne"), | |
| "p10": ("soupe de grenouille (fake)", "sauté de rat (fake)"), | |
| "p11": ("« Cotonou c'est Londres » (fake)", "« Paris, ville de la guerre » (fake)"), | |
| "p12": ("marché d'Arconville (fake)", "Nathan-sur-Seine (fake)"), | |
| } | |
| def card(ax, x, y, w, h, flag, question, answer, verdict, ok): | |
| ax.add_patch(FancyBboxPatch((x, y), w, h, boxstyle="round,pad=0.01,rounding_size=0.02", | |
| linewidth=1.5, edgecolor="#d0d7de", facecolor="#f6f8fa")) | |
| ax.text(x + 0.025, y + h - 0.07, flag, fontsize=15, fontweight="bold", color=INK, va="top") | |
| ax.text(x + 0.025, y + h - 0.17, question, fontsize=17, color=INK, va="top") | |
| ax.text(x + 0.025, y + h - 0.31, "Qwen3.5-4B :", fontsize=13, color=MUTED, va="top") | |
| ax.text(x + 0.025, y + h - 0.39, answer, fontsize=15, color=INK, va="top", style="italic") | |
| color = COLORS["correct"] if ok else COLORS["invented"] | |
| ax.text(x + 0.025, y + 0.07, verdict, fontsize=14, color=color, fontweight="bold", va="bottom") | |
| def banner(path: str) -> None: | |
| fig = plt.figure(figsize=(16, 6), dpi=100) | |
| ax = fig.add_axes((0, 0, 1, 1)) | |
| ax.set_xlim(0, 1) | |
| ax.set_ylim(0, 1) | |
| ax.axis("off") | |
| fig.patch.set_facecolor(BG) | |
| ax.text(0.04, 0.90, "Blind spots of a small LLM: daily life in Benin vs France", | |
| fontsize=26, fontweight="bold", color=INK, va="top") | |
| ax.text(0.04, 0.80, "Same kind of question, same level of fame. Only the country changes.", | |
| fontsize=16, color=MUTED, va="top") | |
| card(ax, 0.04, 0.08, 0.44, 0.62, "Bénin", "« Qu'est-ce qu'un zem à Cotonou ? »", | |
| "« Un marché traditionnel… »", "✗ It's a moto-taxi", ok=False) | |
| card(ax, 0.52, 0.08, 0.44, 0.62, "France", "« Qu'est-ce qu'un Vélib' à Paris ? »", | |
| "« Un système de vélos en libre-service… »", "✓ Correct", ok=True) | |
| fig.savefig(path, facecolor=BG) | |
| plt.close(fig) | |
| def pair_grid(df: pd.DataFrame, path: str) -> None: | |
| pairs = sorted(df["pair_id"].unique()) | |
| fig, ax = plt.subplots(figsize=(10, 0.55 * len(pairs) + 1.4), dpi=120) | |
| ax.set_xlim(0, 2) | |
| ax.set_ylim(0, len(pairs)) | |
| ax.invert_yaxis() | |
| ax.axis("off") | |
| for i, pid in enumerate(pairs): | |
| for j, region in enumerate(["benin", "france"]): | |
| label = df[(df["pair_id"] == pid) & (df["region"] == region)]["label"].iloc[0] | |
| ax.add_patch(plt.Rectangle((j + 0.02, i + 0.06), 0.96, 0.88, color=COLORS[label])) | |
| ax.text(j + 0.05, i + 0.5, SHORT[pid][j], va="center", ha="left", | |
| fontsize=10, color="white", fontweight="bold") | |
| ax.text(j + 0.95, i + 0.5, label, va="center", ha="right", fontsize=9, color="white") | |
| ax.text(0.5, -0.25, "Bénin", ha="center", fontsize=12, fontweight="bold", color=INK) | |
| ax.text(1.5, -0.25, "France", ha="center", fontsize=12, fontweight="bold", color=INK) | |
| fig.savefig(path, bbox_inches="tight", facecolor=BG) | |
| plt.close(fig) | |
| if __name__ == "__main__": | |
| labeled = pd.read_csv("outputs_labeled.csv", dtype=str).fillna("") | |
| banner("banner.png") | |
| pair_grid(labeled, "pairs.png") | |
| print("written banner.png, pairs.png") | |
Xet Storage Details
- Size:
- 3.98 kB
- Xet hash:
- 40f74abe2271ac209cf68bbc43b1e001645980578f612801e4ed764c08809f2d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.