将工具描述从低效的JSON转为高效文本,提升小模型调用准确率。
TSCG: Deterministic Tool-Schema Compilation for Agentic LLM Deployments
- 设计无模型依赖的确定性编译器,把JSON工具描述转成紧凑文本。
- 14B模型在20个工具时准确率从0%提至84.4%,50个工具时达90.3%。
- 适用于小模型部署,特别适合资源受限的生产级智能体系统。
生产级智能体框架(如OpenAI Function Calling、Anthropic Tool Use、MCP)使用为机器解析设计的JSON格式传递工具描述,但该格式不适用于语言模型理解。对4B-14B的小模型而言,这种协议不匹配导致了大多数工具调用失败。本文提出TSCG,一种在API边界上解决此问题的确定性工具模式编译器,无需模型访问、微调或运行时搜索,将JSON模式转换为高效的结构化文本,且具备>=51%的压缩率。在包含约19,000次调用、12种模型、5种场景的TSCG-Agentic-Bench测试中,TSCG使Phi-4 14B模型在20个工具下的准确率从0%恢复至84.4%(50个工具时达90.3%),并在BFCL上实现108-181%的准确率保留比。格式与压缩解耦分析显示,表示形式改变是主要机制(R²从0.88降至0.03)。跨三种前沿模型的逐操作符测试揭示三类响应特征:操作符敏感型(Opus 4.7)、操作符稳健型(Sonnet 4)和操作符依赖型(GPT-5.2),提供模型定制化部署指导。扩展实验表明,在重型生产级MCP模式下,即使轻量合成数据集出现饱和,仍保持+5.0个百分点的准确率优势,且全程节省52-57%的输入token。合成基准结果可泛化至真实MCP模式,误差仅0.1分。TSCG以1,200行零依赖TypeScript代码发布。
原文摘要 · Abstract (English)
Production agent frameworks (OpenAI Function Calling, Anthropic Tool Use, MCP) transmit tool schemas as JSON, a format designed for machine parsing, not for interpretation by language models. For small models (4B-14B), this protocol mismatch accounts for the majority of tool-use failure at production catalog sizes. We present TSCG, a deterministic tool-schema compiler that resolves this mismatch at the API boundary, converting JSON schemas into token-efficient structured text without model access, fine-tuning, or runtime search. TSCG combines eight composable operators with a formal compression bound (>=51% on well-formed schemas). On TSCG-Agentic-Bench (about 19,000 calls, 12 models, 5 scenarios), TSCG restores Phi-4 14B from 0% to 84.4% accuracy at 20 tools (90.3% at 50 tools) and achieves 108-181% accuracy-retained ratio across three models on BFCL. Format-versus-compression decomposition (R^2=0.88 -> 0.03) establishes representation change as the dominant mechanism. Per-operator isolation across three frontier models reveals three distinct operator-response profiles: operator-hungry (Opus 4.7), operator-sensitive (GPT-5.2), and operator-robust (Sonnet 4), providing per-model deployment guidance. Scaling experiments show accuracy advantages persisting on heavy production MCP schemas (+5.0 pp at about 10,500 input tokens) despite saturation on light synthetic catalogs, with 52-57% token savings throughout. The synthetic benchmark generalizes to real MCP schemas within 0.1 accuracy points. TSCG ships as a 1,200-line zero-dependency TypeScript package.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。