让工具库和规划器一起进化,用代码图结构提升大模型的推理能力。
CoCoDA: Co-evolving Compositional DAG for Tool-Augmented Agents

- 用有向无环图组织工具,节点含类型签名与使用规范,支持组合式调用。
- 在数学与代码任务上,8B模型性能追平甚至超过32B教师模型。
- 适合需要长期技能积累与复杂任务分解的研究者或工程应用。
工具增强的语言模型可为小型语言模型赋予外部可执行能力,但工具库规模扩大时面临双重挑战:工具库需随规划器演化以适应新出现的可复用子程序,同时检索过程必须在固定上下文预算内完成。现有工具使用与技能库方法通常将工具视为扁平化或文本索引的记忆体,导致提示成本随库大小线性增长,并掩盖了可执行代码的类型化、组合式结构。我们提出 CoCoDA 框架,通过单一代码原生结构——组合式代码有向无环图(DAG)实现规划器与工具库的协同进化。节点代表原始或复合工具,边表示调用依赖,每个节点存储类型签名、描述、前置/后置条件及示例。推理时,类型化 DAG 检索通过符号签名统一剪枝候选,按描述排序,根据行为规范过滤,并以示例消歧,将高成本的上下文生成逐步聚焦于更小候选集。训练时,成功轨迹被折叠为验证过的复合工具,规划器则通过基于 DAG 的奖励更新,按原始工具扩展规模奖励复合工具。我们提供理论结果:检索成本降低、次线性检索时间、在塑形奖励下展现组合优势、保守更新下单调协同进化以及 DAG 结构良好性。在数学推理、表格分析与代码任务基准测试中,CoCoDA 使 8B 学生模型在 GSM8K 与 MATH 上匹配或超越 32B 教师模型,并持续优于强基准工具使用与库学习方法。
原文摘要 · Abstract (English)
Tool-augmented language models can extend small language models with external executable skills, but scaling the tool library creates a coupled challenge: the library must evolve with the planner as new reusable subroutines emerge, while retrieval from the growing library must remain within a fixed context budget. Existing tool-use and skill-library methods typically treat tools as flat or text-indexed memories, causing prompt cost to grow with library size and obscuring the typed, compositional structure of executable code. We propose CoCoDA, a framework that co-evolves the planner and tool library through a single code-native structure: a compositional code DAG. Nodes are primitive or composite tools, edges encode invocation dependencies, and each node stores a typed signature, description, pre/post-condition specification, and worked examples. At inference time, Typed DAG Retrieval prunes candidates by symbolic signature unification, ranks survivors by descriptions, filters them by behavioral specifications, and disambiguates with examples, keeping expensive context materialization on progressively smaller candidate sets. At training time, successful trajectories are folded into validated composite tools, while the planner is updated with a DAG-induced reward that credits composites by their primitive expansion size. We provide theoretical results showing retrieval cost reduction, sublinear retrieval time, compositional advantage under the shaped reward, monotone co-evolution under conservative updates, and DAG well-formedness. Across mathematical reasoning, tabular analysis, and code task benchmarks, CoCoDA enables an 8B student to match or exceed a 32B teacher on GSM8K and MATH and consistently improves over strong tool-use and library-learning baselines.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。