Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
csv
Size:
< 1K
Tags:
scientific-hypothesis-generation
multi-agent-debate
knowledge-graph
diamond-nv-center
quantum-sensing
llm-as-judge
License:
Download scripts/make_human_eval.py from eduzrh/nv-kgmad: direct link, hf CLI and curl.
- Browser
- Download file 8.31 kB
-
https://huggingface.co/datasets/eduzrh/nv-kgmad/resolve/main/scripts/make_human_eval.py
- Command line
-
hf download hf://datasets/eduzrh/nv-kgmad/scripts/make_human_eval.py
-
curl -L -o make_human_eval.py https://huggingface.co/datasets/eduzrh/nv-kgmad/resolve/main/scripts/make_human_eval.py
8.31 kB
| #!/usr/bin/env python3 | |
| """Build a self-contained, blind human-evaluation form. | |
| Each item shows one research topic and two anonymised hypotheses (KGMAD vs | |
| Multi-Agent). Order is randomised per rater seed and no method names appear, | |
| so raters cannot infer provenance from formatting or vocabulary. Raters fill | |
| the form in a browser and export a CSV; the answer key stays on the researcher | |
| side in ``human_eval/key.csv``. | |
| Usage: | |
| python scripts/make_human_eval.py --n-topics 8 --raters 3 | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import csv | |
| import html | |
| import json | |
| import random | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| OUT = ROOT / "human_eval" | |
| DIMS = [ | |
| ("novelty", "创新性", "1=重复已有工作;3=已有框架内的常规改进;5=提出新机制或可能改变领域做法"), | |
| ("feasibility", "物理可行性", "1=违反物理或量纲错误;3=原理成立但关键参数难以同时满足;5=机制清楚、参数在现有工艺窗口内"), | |
| ("usability", "工程实用性", "1=无法落地;3=可在实验室验证但离应用较远;5=给出可制造工艺路径与封装/标定考虑"), | |
| ("evidence", "数据/文献支撑", "1=无依据或引用与论断无关;3=有部分依据但关键参数缺出处;5=关键论断均有定量证据支撑"), | |
| ("consistency", "理论一致性", "1=与 NV 自旋物理或 ODMR 原理冲突;3=大体自洽但存在未解释的耦合;5=从机制到指标逻辑闭合"), | |
| ] | |
| TEMPLATE = """<!doctype html> | |
| <html lang="zh-CN"><head><meta charset="utf-8"> | |
| <title>科学假设盲评表</title> | |
| <style> | |
| body{{font-family:-apple-system,"Segoe UI","Microsoft YaHei",sans-serif;max-width:980px;margin:0 auto;padding:24px;line-height:1.65;color:#222}} | |
| h1{{font-size:22px}} h2{{font-size:16px;margin-top:34px;padding-top:14px;border-top:1px solid #ddd}} | |
| .meta{{background:#f6f8fa;padding:12px 16px;border-radius:6px;font-size:14px}} | |
| .box{{border:1px solid #e2e2e2;border-radius:6px;padding:14px 18px;margin:10px 0;background:#fff}} | |
| .box h3{{margin:0 0 8px;font-size:15px;color:#0b5}} | |
| .prob{{font-size:13.5px;color:#555;white-space:pre-wrap}} | |
| table{{border-collapse:collapse;width:100%;margin:8px 0}} | |
| td,th{{border-bottom:1px solid #eee;padding:6px 4px;font-size:13.5px;text-align:left;vertical-align:top}} | |
| td.sc{{text-align:center;white-space:nowrap}} | |
| label{{margin:0 3px;cursor:pointer}} | |
| .pref{{margin:12px 0;padding:10px;background:#fffbe6;border-radius:5px;font-size:14px}} | |
| button{{font-size:15px;padding:10px 22px;margin:26px 0;cursor:pointer;background:#0b5;color:#fff;border:0;border-radius:5px}} | |
| .hint{{font-size:12.5px;color:#888}} | |
| </style></head><body> | |
| <h1>科学假设盲评表</h1> | |
| <div class="meta"> | |
| <p><b>背景</b>:每个题目给出一个集成化金刚石 NV 磁传感器的工程难题,以及两份匿名技术方案。 | |
| 两份方案由不同流程生成,版式差异与质量无关,请只看科学内容。</p> | |
| <p><b>怎么打分</b>:对每份方案独立给出 1–5 的整数分(不要给小数)。打分后再回答"哪份更好"。 | |
| <b>请务必先给两份方案各自打分,再看偏好题</b>,否则容易受整体印象影响。</p> | |
| <p><b>用时</b>:约 {minutes} 分钟。中途可刷新,答案保存在本机浏览器里。</p> | |
| <p>评审人代号:<input id="rater" placeholder="例如 r1" style="width:110px;padding:4px"></p> | |
| </div> | |
| {items} | |
| <button onclick="exportCSV()">导出 CSV</button> | |
| <p class="hint">导出后请把 CSV 发回给作者。本页面不联网,所有内容都在本地。</p> | |
| <script> | |
| const DATA = {payload}; | |
| function val(name){{const e=document.querySelector(`input[name="${{name}}"]:checked`);return e?e.value:"";}} | |
| function exportCSV(){{ | |
| const rater=(document.getElementById('rater').value||"anon").trim(); | |
| let rows=[["rater","topic_id","slot","method_hidden","novelty","feasibility","usability","evidence","consistency","preference","confidence","comment"]]; | |
| for(const it of DATA){{ | |
| const pref=val("pref_"+it.topic_id)||""; | |
| const conf=val("conf_"+it.topic_id)||""; | |
| const cm=(document.getElementById("cm_"+it.topic_id)||{{}}).value||""; | |
| for(const slot of ["A","B"]){{ | |
| rows.push([rater,it.topic_id,slot,slot, | |
| val("nov_"+it.topic_id+"_"+slot),val("fea_"+it.topic_id+"_"+slot), | |
| val("usa_"+it.topic_id+"_"+slot),val("evi_"+it.topic_id+"_"+slot), | |
| val("con_"+it.topic_id+"_"+slot), | |
| slot==="A"?pref:(pref==="A"?"B":(pref==="B"?"A":pref)), | |
| conf,cm]); | |
| }} | |
| }} | |
| const csv=rows.map(r=>r.map(x=>`"${{String(x).replace(/"/g,'""')}}"`).join(",")).join("\\n"); | |
| const blob=new Blob(["\\ufeff"+csv],{{type:"text/csv;charset=utf-8"}}); | |
| const a=document.createElement("a"); | |
| a.href=URL.createObjectURL(blob);a.download=`ratings_${{rater}}.csv`;a.click(); | |
| }} | |
| </script></body></html> | |
| """ | |
| ITEM = """ | |
| <h2>题目 {idx}:{title}</h2> | |
| <p class="prob"><b>问题</b>:{problem} | |
| <b>约束</b>:{constraints}</p> | |
| {boxes} | |
| <div class="pref">整体判断:哪一份方案的科学质量更高? | |
| {pref_radios} 置信度:{conf_radios}</div> | |
| <p class="hint">可选:一句话说明理由 <input id="cm_{topic_id}" style="width:70%;padding:4px"></p> | |
| """ | |
| BOX = """ | |
| <div class="box"><h3>方案 {slot}</h3> | |
| <div class="prob">{text}</div> | |
| <table><tr><th style="width:110px">维度</th><th>评分(1–5)</th></tr> | |
| {rows} | |
| </table></div> | |
| """ | |
| def scale(name: str) -> str: | |
| cells = "".join( | |
| f'<label><input type="radio" name="{name}" value="{v}">{v}</label>' for v in range(1, 6) | |
| ) | |
| return f'<td class="sc">{cells}</td>' | |
| def build(n_topics: int, raters: int, seed: int = 20261122) -> None: | |
| OUT.mkdir(exist_ok=True) | |
| topics = {t["id"]: t for t in json.loads((ROOT / "data" / "topics.json").read_text("utf-8"))} | |
| ids = [t for t in sorted(topics) if not t.endswith("9")][:n_topics] | |
| items_html, key_rows, payload = [], [], [] | |
| for i, tid in enumerate(ids, 1): | |
| topic = topics[tid] | |
| texts = {} | |
| for m in ("kgmad", "multi_agent"): | |
| path = ROOT / "outputs" / "hypotheses" / f"{tid}__{m}.json" | |
| texts[m] = json.loads(path.read_text("utf-8"))["text"] | |
| rng = random.Random(seed + i) | |
| order = ["kgmad", "multi_agent"] | |
| rng.shuffle(order) | |
| mapping = {"A": order[0], "B": order[1]} | |
| key_rows.append({"topic_id": tid, "A": mapping["A"], "B": mapping["B"]}) | |
| boxes = "" | |
| for slot in ("A", "B"): | |
| rows = "" | |
| for dim, label, anchor in DIMS: | |
| rows += ( | |
| f'<tr><td>{label}<div class="hint">{anchor}</div></td>' | |
| f'{scale(f"{dim[:3]}_{tid}_{slot}")}</tr>' | |
| ) | |
| body = html.escape(texts[mapping[slot]]) | |
| boxes += BOX.format(slot=slot, text=body.replace("\n", "<br>"), rows=rows) | |
| pref = "".join( | |
| f'<label><input type="radio" name="pref_{tid}" value="{v}">{v if v != "tie" else "平局"}</label> ' | |
| for v in ("A", "B", "tie") | |
| ) | |
| conf = "".join( | |
| f'<label><input type="radio" name="conf_{tid}" value="{v}">{v}</label>' for v in range(1, 6) | |
| ) | |
| items_html.append( | |
| ITEM.format( | |
| idx=i, title=topic["title"], problem=topic["problem"], | |
| constraints=";".join(topic["constraints"]), boxes=boxes, | |
| pref_radios=pref, conf_radios=conf, topic_id=tid, | |
| ) | |
| ) | |
| payload.append({"topic_id": tid}) | |
| page = TEMPLATE.format( | |
| minutes=max(10, len(ids) * 4), items="".join(items_html), | |
| payload=json.dumps(payload, ensure_ascii=False), | |
| ) | |
| (OUT / "盲评表.html").write_text(page, encoding="utf-8") | |
| with (OUT / "key.csv").open("w", newline="", encoding="utf-8-sig") as fh: | |
| w = csv.DictWriter(fh, fieldnames=["topic_id", "A", "B"]) | |
| w.writeheader() | |
| w.writerows(key_rows) | |
| print(f"wrote {OUT/'盲评表.html'} ({len(ids)} topics) and {OUT/'key.csv'}") | |
| if __name__ == "__main__": | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--n-topics", type=int, default=8) | |
| ap.add_argument("--raters", type=int, default=3) | |
| ap.add_argument("--seed", type=int, default=20261122) | |
| a = ap.parse_args() | |
| build(a.n_topics, a.raters, a.seed) |