让大模型学会协作使用海量工具,通过结构化编码提升效率与理解能力。
ToolWeaver: Weaving Collaborative Semantics for Scalable Tool Use in Large Language Models
- 用分层序列编码工具,避免为每个工具新增独立令牌
- 在近4.7万工具上表现超越现有方法,提升可扩展性
- 适合构建能灵活协作的智能助手或自动化代理
现有的基于检索的工具使用流程面临双重语义挑战:检索器使用的编码器难以捕捉复杂语义,而大语言模型本身缺乏从自然语言预训练中获得的工具知识。生成式方法通过统一选择与执行,让模型直接学习并生成工具标识符,但通常将每个工具映射为唯一新标记,导致词汇量爆炸、可扩展性与泛化能力严重受限。该方法还形成语义瓶颈,阻碍模型学习工具间的协作关系,因为只能从大量工具标识符稀疏共现中推断关联。为此,我们提出ToolWeaver,一种新型生成式工具学习框架,将工具编码为层次化序列,使词汇扩展呈对数增长。关键在于,模型可通过共享代码的密集共现学习协作模式,而非依赖孤立工具标识符的稀疏共现。我们设计了一种新颖的分词过程,将工具内在语义与其外部共用模式融合生成结构化代码,并通过生成对齐阶段微调模型以输出此类层次代码序列。在近4.7万工具上的评估表明,ToolWeaver显著优于当前最优方法,建立了更可扩展、可泛化且语义感知更强的工具增强型智能体基础。
原文摘要 · Abstract (English)
Prevalent retrieval-based tool-use pipelines struggle with a dual semantic challenge: their retrievers often employ encoders that fail to capture complex semantics, while the Large Language Model (LLM) itself lacks intrinsic tool knowledge from its natural language pretraining. Generative methods offer a powerful alternative by unifying selection and execution, tasking the LLM to directly learn and generate tool identifiers. However, the common practice of mapping each tool to a unique new token introduces substantial limitations: it creates a scalability and generalization crisis, as the vocabulary size explodes and each tool is assigned a semantically isolated token. This approach also creates a semantic bottleneck that hinders the learning of collaborative tool relationships, as the model must infer them from sparse co-occurrences of monolithic tool IDs within a vast library. To address these limitations, we propose ToolWeaver, a novel generative tool learning framework that encodes tools into hierarchical sequences. This approach makes vocabulary expansion logarithmic to the number of tools. Crucially, it enables the model to learn collaborative patterns from the dense co-occurrence of shared codes, rather than the sparse co-occurrence of monolithic tool IDs. We generate these structured codes through a novel tokenization process designed to weave together a tool's intrinsic semantics with its extrinsic co-usage patterns. These structured codes are then integrated into the LLM through a generative alignment stage, where the model is fine-tuned to produce the hierarchical code sequences. Evaluation results with nearly 47,000 tools show that ToolWeaver significantly outperforms state-of-the-art methods, establishing a more scalable, generalizable, and semantically-aware foundation for advanced tool-augmented agents.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。