"""Build a self-contained reproduction poster (poster.html -> poster.png data-URI) and poster_embed.html with accessible hotspots linking to the logbook claim pages. Figures are rendered with matplotlib from the result JSONs (no external assets).""" import os, sys, json, base64, io import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) OUT = os.path.join(BASE, "outputs", "poster") os.makedirs(OUT, exist_ok=True) GEN = "Qwen/Qwen2.5-32B-Instruct-AWQ" ACCENT = "#2D5F8B"; DEEP = "#1F4566"; EMPH = "#C9A24A"; GREEN = "#2ca02c"; RED = "#d62728" SLUGS = { "c1": "claim-1-mindflow-formulates-research-ideation-as-graph-structured-flow-composed-of-modular-thinking-operators-and-probabilistic-mind-supernet", "c2": "claim-2-mindflow-shows-superiority-as-explicit-controllable-and-optimizable-research-idea-innovator-across-diverse-topics", "c3": "claim-3-tournament-based-relative-ranking-enables-the-controller-to-progressively-favor-higher-quality-thinking-flows", } def load(claim): p = os.path.join(BASE, "outputs", claim, f"{claim}_results.json") return json.load(open(p)) if os.path.exists(p) else None def datauri(fig): b = io.BytesIO(); fig.savefig(b, format="png", dpi=150, bbox_inches="tight", facecolor="white") plt.close(fig); b.seek(0) return "data:image/png;base64," + base64.b64encode(b.read()).decode() def fig_heatmap(c1): ops = c1["ctrl_ops"]; heat = c1["heatmap"]; doms = list(heat.keys()) Z = np.array([[heat[d][o] for o in ops] for d in doms]) fig, ax = plt.subplots(figsize=(5.2, 3.4)) im = ax.imshow(Z, cmap="viridis", vmin=0, vmax=1, aspect="auto") ax.set_xticks(range(len(ops))); ax.set_xticklabels(ops, rotation=40, ha="right", fontsize=8) ax.set_yticks(range(len(doms))); ax.set_yticklabels(doms, fontsize=8) fig.colorbar(im, ax=ax, fraction=0.035).ax.tick_params(labelsize=7) ax.set_title("Mind-supernet P(include operator) by domain", fontsize=10, color=DEEP, weight="bold") return datauri(fig) def fig_claim2(c2): methods = [k for k in c2 if not k.startswith("_")] order = sorted(methods, key=lambda m: c2[m]["agg"]["Overall"]) names = order; ov = [c2[m]["agg"]["Overall"] for m in order] cols = [EMPH if m == "MindFlow" else ACCENT for m in order] fig, ax = plt.subplots(figsize=(5.2, 3.4)) ax.barh(names, ov, color=cols) for i, v in enumerate(ov): ax.text(v + 0.005, i, f"{v:.3f}", va="center", fontsize=8) ax.set_xlabel("Overall win-rate MOScore vs expert", fontsize=9) ax.set_title("Claim 2 — MindFlow best aggregate", fontsize=10, color=DEEP, weight="bold") ax.tick_params(labelsize=8); ax.set_xlim(0, max(ov) * 1.18) return datauri(fig) def fig_claim3(c3): fig, ax = plt.subplots(figsize=(5.2, 3.4)) for mode, col in [("tournament", GREEN), ("pointwise", RED)]: if mode in c3: h = c3[mode]["hist"] ax.plot(h["eval_iter"], h["eval_overall"], "-o", color=col, label=mode, lw=2, ms=4) ax.set_xlabel("Optimization iteration", fontsize=9); ax.set_ylabel("Held-out MOScore", fontsize=9) ax.set_title("Claim 3 — tournament vs pointwise", fontsize=10, color=DEEP, weight="bold") ax.legend(fontsize=8); ax.tick_params(labelsize=8); ax.grid(alpha=0.3) return datauri(fig) def fig_reward(c3): fig, ax = plt.subplots(figsize=(5.2, 2.7)) for mode, col in [("tournament", GREEN), ("pointwise", RED)]: if mode in c3: rs = c3[mode]["hist"]["reward_std"] ax.plot(range(1, len(rs) + 1), rs, "-", color=col, label=f"{mode} (μ={np.mean(rs):.2f})", lw=2) ax.set_xlabel("Iteration", fontsize=9); ax.set_ylabel("Reward std", fontsize=9) ax.set_title("Reward discrimination (↑ = less judgment collapse)", fontsize=9, color=DEEP, weight="bold") ax.legend(fontsize=8); ax.tick_params(labelsize=8); ax.grid(alpha=0.3) return datauri(fig) def build(): c1, c2, c3 = load("claim1"), load("claim2"), load("claim3") mf = c2["MindFlow"]["agg"]["Overall"] methods = [k for k in c2 if not k.startswith("_")] bb_name = max((m for m in methods if m != "MindFlow"), key=lambda m: c2[m]["agg"]["Overall"]) bb = c2[bb_name]["agg"]["Overall"] t_ov = c3["tournament"]["hist"]["eval_overall"]; p_ov = c3["pointwise"]["hist"]["eval_overall"] t_rstd = float(np.mean(c3["tournament"]["hist"]["reward_std"])) p_rstd = float(np.mean(c3["pointwise"]["hist"]["reward_std"])) imgs = {"heat": fig_heatmap(c1), "c2": fig_claim2(c2), "c3": fig_claim3(c3), "rew": fig_reward(c3)} html = f"""