通过自我改进扩充 library
library 是 agent 从自己的开发 episode 中学到的东西:用于 prompt 的经验、可供回忆的记忆,以及代码。scripts/self_improve.py 在开发 seed 上扩充一个 library,并且只有当某个条目能提高其他开发 seed 上的分数时才保留它;之后评测使用冻结的 library。
library
Section titled “library”library/├── notes/*.md lessons, added to the system prompt ("Lessons from earlier episodes")├── memory/*.md entries programs read with recall(query, k=5) (ranked by word overlap)├── skills/*.py functions run in the kernel before the first program; listed in the prompt└── reactive/*.py guards and controllers; loaded only when the reactive skill is on它的版本是它所用每个条目(路径和内容)的 sha256。agent 这样使用一个 library:
[runtime.library]path = "../../library/r4" # relative to this filelayers = ["notes", "skills", "reactive"]该版本会写入 lock;如果 library 在配置加载之后发生了变化,driver 会拒绝运行 episode:评测需要冻结的 library。
python scripts/self_improve.py --experiment configs/experiments/dev.toml --deploy mine \ --tasks stack_bowls,classify_objects --explore-seeds 0-3 --validate-seeds 10-13 \ --library library/r4 --gpu 3 --output runs/self-improve对每个任务(重复 --rounds 次):
- 用当前 library 运行 explore seed;
- 对每个探索过的 episode,向主模型(temperature 0.3)请求一个候选:
<note|memory|skill|reactive name="...">...</...>或<none/>。note 最多 600 个字符;代码必须能解析,并且恰好定义一个带 docstring 的公有函数; - 加入候选后运行 validate seed,如果平均分比当前 library 的平均分至少提高
--min-gain(默认 0.05),就保留它。
explore seed 和 validate seed 不能重叠;两者都是开发 layout。决策写入 OUTPUT/decisions.json,最终 library 的清单写入 OUTPUT/library.json。参数:--experiment(agent、其模型、预算)、--deploy、--set、--tasks、--explore-seeds、--validate-seeds、--library、--min-gain、--rounds、worker 的 --gpu 和 --port、--dev-layout-dir、--output。