arxiv.org·2026/10/26
针对聊天助手用动画解释概念时声明式规格是否比自由形式HTML/JavaScript更省、更快、更可靠的假设,作者设计ExplainSpec时间索引声明式格式与统一观察契约,用跨物理、算法、协议、机器学习、概率的多个任务及经过变异测试的节奏无关检查器,对三款Claude模型和Qwen3-14B(思考开关)做预先注册的对照实验。结果显示规格的答案token短25–48%,但启用推理时仅最大Claude模型总输出显著下降,所有模型生成速度都未显著加快:Claude模型写规格前推理大幅增多,Qwen3-14B两种格式推理量相近且推理长度超过答案两倍。可靠性也未提高,自由形式页面经一次修复后对每个模型95–100%有效,而Qwen3-14B的规格仅33%有效、通过全部语义测试仅17%(HTML/JS为62%)。结论是输出压缩不等于生成节省,在上下文中现学的格式反而可能损害可靠性;未来需测试模型训练过的格式并分析推理内容。
为什么重要 直接推翻「声明式格式省延迟省成本」的直觉,影响生成式 UI 架构选型与推理成本估算适合 生成式 UI 架构师、LLM 输出格式选型与推理成本优化工程师
聊天助手越来越多地用交互式动画解释来回答概念性问题,这些解释要么生成为自由形式的 HTML/JavaScript,要么生成为由固定运行时播放的声明式规格。由于声明式输出更短且受约束,它被普遍预期更便宜、更快、更可靠。我们在受控比较中检验了这一预期,其假设和分析计划在运行前已被冻结。我们设计了 ExplainSpec,一种时间索引的声明式动画格式,以及一个观察契约,使每个生成的解释都可编程检查;经验证的、与节奏无关的检查器对来自五个领域的 20 个解释请求进行评分。三个 Claude 模型(360 个任务)以及后续的开放权重 Qwen3-14B(启用和禁用思考,240 个任务)对每个请求用两种格式作答。
对所有模型而言,规格在答案 token(输出不含推理)上短 25–48%,但启用推理时,总输出仅在最大的 Claude 模型上显著下降,且没有模型生成速度显著更快。原因各不相同。Claude 模型在编写规格前进行了更多推理(探索性;对两个较大的模型,从 15–20% 到 85–88% 的生成中如此)。Qwen3-14B 在两种格式中的推理量大致相同(针对这一变化的预注册检验未获支持),其更短的答案相比两倍多长的推理 trace 节省甚微。
规格也并未更可靠:自由形式页面经过一轮修复后在每个模型的 95–100% 任务中有效,而 Qwen3-14B 仅在 33% 的任务中生成了有效规格,并通过全部语义测试的比例为 17%(HTML/JavaScript 为 62%)。因此,对于推理模型,仅靠更短的格式并不能使生成更便宜、更快或更可靠,而在上下文中习得的格式可能以可靠性为代价。
Chat assistants increasingly answer conceptual questions with interactive, animated explanations, generated either as free-form HTML/JavaScript or as declarative specifications that a fixed runtime plays.
The declarative route is widely expected to be cheaper, faster and more reliable, because its outputs are shorter and constrained.
We test this expectation in controlled comparisons whose hypotheses and analysis plans were frozen before the runs.
We designed ExplainSpec, a time-indexed declarative animation format, and an observation contract that makes every generated explanation programmatically inspectable; validated, pacing-agnostic checkers score 20 explanation requests from five domains.
Three Claude models (360 jobs) and, in a follow-up, the open-weight Qwen3-14B with thinking enabled and disabled (240 jobs) answered every request in both formats.
For every model the specifications were 25-48% shorter in answer tokens (output excluding reasoning), yet with reasoning enabled total output fell significantly only for the largest Claude model and no model generated significantly faster.
The reasons differed. The Claude models reasoned far more before writing specifications (exploratory; for the two larger models, from 15-20% to 85-88% of generations).
Qwen3-14B reasoned about as much in both formats (a pre-registered test of this shift was not supported), and its shorter answers saved little against a reasoning trace more than twice as long.
Nor were specifications more reliable: free-form pages were valid after one repair round in 95-100% of jobs for every model, whereas Qwen3-14B produced valid specifications in only 33% of jobs and passed all semantic tests in 17% (HTML/JavaScript: 62%).
For reasoning models, a shorter format alone therefore does not make generation cheaper, faster or more reliable, and a format learned in context can cost reliability.
答案缩短
四个模型一致
总输出降低
ratio 0.81, p=0.040
HTML/JS 有效率
修复后,所有模型
Qwen3 Spec 语义
HTML/JS 为 62%
注释 · answer tokens 不含 术语解释推理模型在输出最终答案前生成的隐藏思考 token,Claude 称 thinking tokens,不计入 answer tokens;语义指通过全部状态轨迹检查出自 Abstract, §5–6
注释 · effort low 下 HTML/JS 几乎不推理,Spec 触发大量推理出自 §5.2, 表 2

EVIDENCE / METHODS
表格
Qwen3-14B Spec 语义通过率 17%,不到 HTML/JS 的三分之一
| 模型 | 格式 | 答案 token | 推理 token | 语义通过率 |
|---|---|---|---|---|
| Opus | HTML/JS | 2,795 | 0 | 100% |
| Opus | Spec | 2,043 | 402 | 95% |
| Sonnet | HTML/JS | 2,558 | 0 | 95% |
| Sonnet | Spec | 1,822 | 933 | 90% |
| Haiku | HTML/JS | 2,926 | 2,454 | 93% |
| Haiku | Spec | 1,706 | 4,710 | 83% |
| Qwen3-14B | HTML/JS | 1,559 | 3,370 | 62% |
| Qwen3-14B | Spec | 906 | 3,686 | 17% |
注释 · token 为首次尝试中位数;语义通过率为修复后出自 表 2, 表 7
原版排版与图表 · 手机无法内嵌时可在浏览器打开。PDF 插件内选文不能传给网页助手。