debajyotidasgupta's picture
MindFlow reproduction bundle
448d6a5 verified
Raw
History Blame Contribute Delete
12.8 kB
"""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"""<!-- poster_embed.html source poster -->
<div id="poster" style="width:1600px;height:900px;box-sizing:border-box;font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;background:#fff;color:#1a2733;padding:26px 30px;position:relative;border:1px solid #e5e9ee;">
<div style="border-bottom:6px solid {ACCENT};padding-bottom:10px;margin-bottom:14px;">
<div style="font-size:31px;font-weight:800;color:{DEEP};line-height:1.1;">MindFlow: Mind Supernet Powered Thinking Flows for Research Idea Innovation</div>
<div style="font-size:15px;color:#4a5a6a;margin-top:5px;">Independent reproduction of ICML 2026 #1894 (OpenReview GgINST3Qgc) · open backbone <b>{GEN}</b> via vLLM · all three core claims reproduce at mechanism scale</div>
</div>
<div style="display:grid;grid-template-columns:1.02fr 1fr 1fr;gap:16px;height:720px;">
<!-- Col 1: method -->
<div style="display:flex;flex-direction:column;gap:12px;">
<div style="background:#F4F8FB;border:1px solid #dde6ee;border-radius:10px;padding:12px 14px;">
<div style="font-size:17px;font-weight:700;color:{DEEP};margin-bottom:6px;">The idea</div>
<div style="font-size:13.5px;line-height:1.45;">Research ideation is <b>open-ended</b> and <b>multi-objective</b> (novelty · plausibility · feasibility). MindFlow makes the thinking process <b>explicit, controllable & optimizable</b>:</div>
<ul style="font-size:13px;line-height:1.5;margin:8px 0 0 16px;padding:0;">
<li><b>Thinking flow</b> — a DAG over 8 modular operators (Generate, Divergent, Convergent, Critical, Analogical, Counterfactual, Constraint-Driven, Exit).</li>
<li><b>Mind supernet</b> — layer-wise operator inclusion probs π<sub>ℓ</sub>(O|topic); a controller samples topic-specific flows.</li>
<li><b>Tournament ranking</b> — REINFORCE on relative ranks of K flows, not noisy absolute scores.</li>
</ul>
</div>
<div style="background:{DEEP};color:#fff;border-radius:10px;padding:12px 14px;">
<div style="font-size:16px;font-weight:700;margin-bottom:6px;">Reproduction outcome</div>
<div style="font-size:13.5px;line-height:1.5;">✔ <b>Claim 1</b> — supernet instantiates a topic-varying distribution over composable flows.<br>
✔ <b>Claim 2</b> — trained controller wins aggregate MOScore <b>{mf:.3f}</b> vs best baseline {bb_name} {bb:.3f}.<br>
✔ <b>Claim 3</b> — tournament reward (std {t_rstd:.2f}) beats collapsed pointwise (std {p_rstd:.2f}); held-out MOScore {t_ov[0]:.3f}{t_ov[-1]:.3f}.</div>
</div>
<div style="background:#FFF7E6;border:1px solid {EMPH};border-radius:10px;padding:10px 14px;font-size:12px;line-height:1.45;">
<b>Scope & cost.</b> 8-query IdeaBench proxy (vs paper's 3,495 papers); 1× RTX 6000 Ada, ~1 hr, ~\\$1–3. Backbone substitution (open 32B) for the paper's unstated closed LLM; 3-judge panel emulated by one model + order randomization.</div>
</div>
<!-- Col 2: claim 1 + claim 2 -->
<div style="display:flex;flex-direction:column;gap:12px;">
<div data-target="{SLUGS['c1']}" style="background:#fff;border:1px solid #dde6ee;border-radius:10px;padding:10px 12px;position:relative;">
<div style="font-size:15px;font-weight:700;color:{DEEP};">Claim 1 · graph-structured supernet <span style="float:right;font-size:11px;color:{ACCENT};">Open details ↗</span></div>
<img src="{imgs['heat']}" style="width:100%;margin-top:6px;border-radius:6px;"/>
<div style="font-size:12px;color:#456;margin-top:4px;">Non-uniform, topic-varying operator preferences → a genuine probabilistic supernet.</div>
</div>
<div data-target="{SLUGS['c2']}" style="background:#fff;border:1px solid #dde6ee;border-radius:10px;padding:10px 12px;position:relative;">
<div style="font-size:15px;font-weight:700;color:{DEEP};">Claim 2 · superiority across topics <span style="float:right;font-size:11px;color:{ACCENT};">Open details ↗</span></div>
<img src="{imgs['c2']}" style="width:100%;margin-top:6px;border-radius:6px;"/>
</div>
</div>
<!-- Col 3: claim 3 -->
<div data-target="{SLUGS['c3']}" style="display:flex;flex-direction:column;gap:10px;background:#fff;border:1px solid #dde6ee;border-radius:10px;padding:10px 12px;position:relative;">
<div style="font-size:15px;font-weight:700;color:{DEEP};">Claim 3 · tournament ranking optimizes the controller <span style="float:right;font-size:11px;color:{ACCENT};">Open details ↗</span></div>
<img src="{imgs['c3']}" style="width:100%;border-radius:6px;"/>
<img src="{imgs['rew']}" style="width:100%;border-radius:6px;"/>
<div style="font-size:12px;color:#456;">Relative ranking always spreads candidates across ranks 0..K-1 → stable gradient; absolute scoring collapses into a narrow band ('judgment collapse') and barely moves the controller.</div>
</div>
</div>
<div style="position:absolute;bottom:14px;left:30px;right:30px;border-top:2px solid #e5e9ee;padding-top:8px;font-size:11.5px;color:#5a6a7a;display:flex;justify-content:space-between;">
<span>Reproduction logbook · Trackio · backbone {GEN} · encoder all-MiniLM-L6-v2</span>
<span>ICML 2026 open-reproduction challenge</span>
</div>
</div>"""
open(os.path.join(OUT, "poster.html"), "w").write(html)
print("wrote poster.html", flush=True)
return html
def render_png():
from playwright.sync_api import sync_playwright
src = os.path.join(OUT, "poster.html")
png = os.path.join(OUT, "poster.png")
full = "<!doctype html><html><head><meta charset='utf-8'></head><body style='margin:0'>" + open(src).read() + "</body></html>"
tmp = os.path.join(OUT, "_poster_full.html"); open(tmp, "w").write(full)
with sync_playwright() as p:
b = p.chromium.launch(); pg = b.new_page(viewport={"width": 1600, "height": 900}, device_scale_factor=2)
pg.goto("file://" + tmp); pg.wait_for_timeout(400)
el = pg.query_selector("#poster"); el.screenshot(path=png)
b.close()
print("wrote poster.png", os.path.getsize(png), flush=True)
return png
def build_embed():
png = os.path.join(OUT, "poster.png")
uri = "data:image/png;base64," + base64.b64encode(open(png, "rb").read()).decode()
# hotspots (percentages of the 1600x900 canvas) over the three claim regions
spots = [
{"slug": SLUGS["c1"], "label": "Claim 1 details", "x": 35.0, "y": 20.0, "w": 31.5, "h": 33.0},
{"slug": SLUGS["c2"], "label": "Claim 2 details", "x": 35.0, "y": 55.0, "w": 31.5, "h": 33.0},
{"slug": SLUGS["c3"], "label": "Claim 3 details", "x": 67.5, "y": 20.0, "w": 31.5, "h": 68.0},
]
btns = "\n".join(
f'<a class="hot" href="#/{s["slug"]}" target="_top" aria-label="{s["label"]}" '
f'style="left:{s["x"]}%;top:{s["y"]}%;width:{s["w"]}%;height:{s["h"]}%;" title="{s["label"]}">'
f'<span class="pill">Open details ↗</span></a>' for s in spots)
html = f"""<!-- poster_embed.html : self-contained reproduction poster with accessible hotspots -->
<div class="poster-embed" style="position:relative;max-width:100%;margin:0 auto;">
<style>
.poster-embed img{{width:100%;display:block;border-radius:8px;}}
.poster-embed .hot{{position:absolute;display:flex;align-items:flex-start;justify-content:flex-end;
border:2px solid transparent;border-radius:8px;text-decoration:none;transition:.15s;}}
.poster-embed .hot:hover,.poster-embed .hot:focus{{border-color:#2D5F8B;background:rgba(45,95,139,.08);outline:none;}}
.poster-embed .pill{{margin:6px;background:#2D5F8B;color:#fff;font:600 11px/1 -apple-system,Segoe UI,Arial;
padding:4px 8px;border-radius:12px;opacity:.85;}}
.poster-embed .hot:hover .pill,.poster-embed .hot:focus .pill{{opacity:1;}}
</style>
<img src="{uri}" alt="MindFlow reproduction poster"/>
{btns}
</div>"""
open(os.path.join(OUT, "poster_embed.html"), "w").write(html)
print("wrote poster_embed.html", os.path.getsize(os.path.join(OUT, "poster_embed.html")), flush=True)
if __name__ == "__main__":
build(); render_png(); build_embed()
print("poster done ->", OUT)