Spaces:
Running
Running
Download src/Help.tsx from dsh-marl/trajectory-explorer: direct link, hf CLI and curl.
- Browser
- Download file 8.58 kB
-
https://huggingface.co/spaces/dsh-marl/trajectory-explorer/resolve/main/src/Help.tsx
- Command line
-
hf download hf://spaces/dsh-marl/trajectory-explorer/src/Help.tsx
-
curl -L -o Help.tsx https://huggingface.co/spaces/dsh-marl/trajectory-explorer/resolve/main/src/Help.tsx
8.58 kB
| // The "说明" drawer: what everything on the page means. Open it anywhere with openHelp(section). | |
| import { useEffect, useRef, useState } from "react"; | |
| import { opLabel } from "./feed"; | |
| import { opHelp, stateHelp } from "./explain"; | |
| import { opColor, stateIcon, stateLabel, type NodeState } from "./replay"; | |
| export const openHelp = (section?: string) => dispatchEvent(new CustomEvent("help", { detail: section ?? "" })); | |
| export function HelpLink({ section, label = "?" }: { section: string; label?: string }) { | |
| return <button className="helpbtn" title="这是什么?" onClick={(e) => { e.stopPropagation(); openHelp(section); }}>{label}</button>; | |
| } | |
| const Dt = ({ k, children }: { k: React.ReactNode; children: React.ReactNode }) => <div className="h-row"><div className="h-k">{k}</div><div>{children}</div></div>; | |
| export default function HelpDrawer() { | |
| const [open, setOpen] = useState<string | null>(null); | |
| const box = useRef<HTMLDivElement>(null); | |
| useEffect(() => { | |
| const f = (e: Event) => setOpen((e as CustomEvent).detail || "page"); | |
| const k = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(null); }; | |
| addEventListener("help", f); addEventListener("keydown", k); | |
| return () => { removeEventListener("help", f); removeEventListener("keydown", k); }; | |
| }, []); | |
| useEffect(() => { | |
| if (!open || !box.current) return; | |
| const el = box.current.querySelector(`#help-${open}`) as HTMLElement | null; | |
| box.current.scrollTo({ top: el ? el.offsetTop - box.current.offsetTop - 12 : 0 }); | |
| el?.classList.add("flash"); setTimeout(() => el?.classList.remove("flash"), 1200); | |
| }, [open]); | |
| if (!open) return null; | |
| return ( | |
| <div className="drawer-bg" onClick={() => setOpen(null)}> | |
| <aside className="drawer" onClick={(e) => e.stopPropagation()}> | |
| <div className="m-h"><h3>说明</h3><span className="sub">Esc 关闭</span> | |
| <button className="iconbtn" style={{ marginLeft: "auto" }} onClick={() => setOpen(null)}>✕</button></div> | |
| <div className="drawer-b" ref={box}> | |
| <section id="help-page"> | |
| <h4>这页怎么看</h4> | |
| <p>左边<b>改动</b>:每张卡是一次子 agent 运行,写着它接到哪个子任务、改了哪些文件、改动有没有留下来;最底下是最终交卷的代码改动。</p> | |
| <p>右边<b>团队活动</b>:按时间顺序记下 orchestrator 说了什么、做了什么操作,以及它派出的子 agent 做了什么。</p> | |
| <p>点左边的卡,右边跳到对应位置;点文件名看这个文件的 diff;点「回放」从头按顺序重演一遍。</p> | |
| </section> | |
| <section id="help-how"> | |
| <h4>一道题是怎么跑的</h4> | |
| <p>一道题 = 一个真实的代码仓库 + 要实现的几个<b>特征</b>(来自同一个 PR)。</p> | |
| <p><b>orchestrator</b>(我们训练的模型)不写代码,只管拆任务、派人。<b>子 agent</b>(未训练的同款模型)在同一个仓库里依次动手改代码。</p> | |
| <p>所有子任务组成一张<b>任务图</b>:根任务 t1 就是整道题;拆分后得到 t2、t3……子任务之间可以有<b>依赖</b>,A → B 表示 B 要等 A 做完,并拿到 A 的结果。被拆分的任务变成<b>汇总步骤</b>,等它拆出来的子任务都完成后再执行一次。</p> | |
| <p id="help-frontier"><b>可开始(frontier)</b>:状态是待办、而且依赖都已完成的子任务。只有可开始的子任务才能拆分或指派。报错里的 <code>not on the frontier</code> 就是说它还在等别的子任务。</p> | |
| <p><b>验收检查</b>:每个子 agent 改完后,跑一遍仓库原有的测试;有原本通过的测试被改挂了,就撤销这次改动。</p> | |
| <p><b>隐藏测试</b>:结束后用题目自带、agent 看不到的测试给最终代码打分。</p> | |
| </section> | |
| <section id="help-ops"> | |
| <h4>orchestrator 的操作</h4> | |
| {Object.keys(opHelp).map((op) => ( | |
| <Dt key={op} k={<span className="optag" style={{ ["--c" as any]: opColor(op) }}>{opLabel[op]}</span>}>{opHelp[op].replace(/^[^:]+:/, "")}<span className="h-en"> {op}</span></Dt> | |
| ))} | |
| <Dt k={<span className="tag bad">被拒绝</span>}>操作不符合规则,没有生效,环境把原因返回给 orchestrator。下面一行中文是解释,灰色小字是环境的原始报错。</Dt> | |
| </section> | |
| <section id="help-states"> | |
| <h4>子 agent 运行的结果</h4> | |
| {(["accepted", "rejected", "nochange", "failed", "done", "running"] as NodeState[]).map((s) => ( | |
| <Dt key={s} k={<span className={"tag " + (s === "accepted" || s === "done" ? "good" : s === "rejected" ? "bad" : s === "failed" ? "warn" : "plain")}>{stateIcon[s]} {stateLabel[s]}</span>}> | |
| {stateHelp[s].replace(/^[^:]+:/, "")}</Dt> | |
| ))} | |
| <Dt k="测试 560 → 564">这次改动前后,仓库原有测试的通过个数。括号里是变化。</Dt> | |
| <Dt k={<span className="fpill gone">a.py</span>}>文件名划线:这个文件被它改过,但最终改动里没有(被撤销了,或后来又改回原样)。</Dt> | |
| <Dt k="第 2 次">同一个子任务被重试,这是第几次执行。</Dt> | |
| </section> | |
| <section id="help-scores"> | |
| <h4>分数</h4> | |
| <Dt k="特征通过">一个特征的隐藏测试全部通过,才算这个特征通过。特征小块上的 62/66 是这个特征通过了几个测试。</Dt> | |
| <Dt k="S">通过的特征占比。</Dt> | |
| <Dt k="R">每个特征算通过测试的占比(只算原本不通过、应该被修好的测试),再对特征取平均。R 就是训练用的奖励。</Dt> | |
| <Dt k="token a + b">orchestrator 用的 token + 所有子 agent 用的 token。</Dt> | |
| <Dt k="训练第 N 步">这条轨迹出自第几步训练。每一步每道题跑 4 次。</Dt> | |
| <Dt k="优势">这次的 R 比同一步同一道题 4 次的平均好多少(除以标准差)。正数的做法会被强化,负数的被抑制。</Dt> | |
| </section> | |
| <section id="help-records"> | |
| <h4>数学和 AgentGym 这两条线</h4> | |
| <p>这两条线早于 CooperBench:同一个模型既当 <b>lead</b> 也当<b>队友</b>。lead 自己解题,觉得需要时用 <code>spawn_teammate</code> 派队友(数学里是 Solver 解题或 Verifier 验算),队友做完把结果回给 lead。</p> | |
| <Dt k="avg@16">每道题独立做 16 次,取答对比例的平均,按百分比写。</Dt> | |
| <Dt k="派队友比例">测试或训练的局里,lead 至少派了一个队友的局所占的比例。</Dt> | |
| <Dt k="主局 / 副本">AgentGym 里只有 lead 能在主局里走,主局的结果算分;副本是复制出来的同一局,用来试走,不算分。</Dt> | |
| <Dt k="SciWorld 口径">SciWorld 一局可能扣到 −100 分。旧口径把负分截成 0,官方口径不截。表里用官方口径,旧口径写在格子的提示里。</Dt> | |
| <p>这两条线的训练模型和大部分对话在清理服务器时已经删掉,只剩训练曲线、各存档的测试分、每局的统计和少数几局完整对话。</p> | |
| </section> | |
| <section id="help-end"> | |
| <h4>怎么结束的</h4> | |
| <Dt k="orchestrator 主动结束">orchestrator 调用了「结束」。</Dt> | |
| <Dt k="超时">整道题的时间用完了,按当时仓库的状态打分。</Dt> | |
| <Dt k="轮数用尽">orchestrator 的对话轮数用完了。</Dt> | |
| <Dt k="没有调用工具">orchestrator 回了一段话但没有调用任何工具,对话结束。</Dt> | |
| <Dt k="模型接口报错">对话太长等原因,模型接口返回错误,对话结束。</Dt> | |
| <Dt k="步数用尽">单 agent 对照组的步数上限到了。</Dt> | |
| </section> | |
| <section id="help-gaps"> | |
| <h4>这版数据缺什么</h4> | |
| <p>工具输出在记录时截到 2000 字;子 agent 自己的思考没有记录,只有它的操作、看到的输出和最终回报;每个子 agent 各自的 diff 没有记录,点文件看到的是最终 diff;训练轨迹和较早的测评没有验收日志,结果只能显示「完成」。</p> | |
| </section> | |
| </div> | |
| </aside> | |
| </div> | |
| ); | |
| } | |