Manuscript Offprint

arXiv:2610.32129

Shorter Is Not Cheaper: A Controlled Comparison of Declarative Animation Specifications and Free-Form Code for LLM-Generated Explanations

Jiantang Huang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

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.

Keywords Generative UI · Declarative animation · LLM output representation · Latency · Reasoning tokens

1 Introduction

Interactive, visual answers have become a standard capability of chat assistants: deployed systems explain mathematics and science with parameterised visuals and simulations inside the conversation [1–4]. Because such explanations are generated on demand, while the user waits, their generation cost and latency matter as much as their quality. Two ways of producing them coexist. The model can write a complete, self-contained HTML/JavaScript page, which is maximally expressive but long: complete generated pages can take a minute or more [5]. Alternatively, the model can emit a compact declarative description that a trusted, prebuilt runtime renders, the approach taken by generative UI catalogs such as A2UI, json-render and OpenUI [6–8] and, according to its announcement, by ChatGPT's Intelligent UI [4].

The case for the declarative route rests on two intuitions. First, because decoding output tokens dominates generation latency [9], a shorter artifact should arrive sooner and cost less. Second, a constrained format with a validating runtime should fail less often than free-form code. Neither intuition has been tested under controlled conditions for animated explanations, and the indirect evidence points in different directions: a structured trace pipeline for algorithm videos improved correctness but was reported to consume more tokens than direct code [10]; a harness that generates

A PREPRINT

component-constrained UI code reported fewer output tokens than raw HTML without controlling for quality [11]; format restrictions can interact with reasoning [12–14]; and frontier models already produce running interactive pages most of the time, although often with wrong content [15].

Testing these intuitions fairly is harder than it appears. The two formats must convey the same content, so that differences can be attributed to the representation rather than to the task; correctness must be checked for animated, parameterised output regardless of how the model paces its animation; and the generating model must be isolated from the experimenter's tools and instructions. We meet these requirements as follows. Both formats implement one programmatic observation contract, so that the same checkers apply to both. The checkers compare state traces with ground truth independently of pacing, and they were validated against independent reference implementations and by mutation testing before any model output existed. Every generation runs in an isolated process, and the hypotheses, measures and analysis plan were written down and frozen before the main run. Within this design, three Claude models of different sizes answered 20 requests in physics, algorithms, network protocols, machine learning and probability, three times in each format, with one repair round for invalid artifacts. In a follow-up with its own frozen plan, we repeated the study with an open-weight reasoning model from another family, Qwen3-14B, run locally with thinking enabled and, as an ablation, disabled.

The results do not support either intuition for the models we tested (fig. 2, section 6). With reasoning enabled, the specifications are 25–48% shorter in answer tokens for all four models, yet generation is not significantly faster for any of them, and total output falls significantly only for the largest Claude model. Why the saving vanishes differs between the families: the Claude models reason far more before writing a specification, whereas Qwen3-14B, for which a pre-registered test of this shift was not supported, reasons at length in both formats, so that its much shorter answer changes the total little. Nor is the constrained format more reliable. Free-form pages are valid after at most one repair round in 95–100% of jobs for every model, while specifications are less often valid; for Qwen3-14B they pass all semantic tests in only 17% of jobs, against 62% for HTML/JavaScript. The central lesson is that output compression and generation savings are different quantities: what a reasoning model writes is only part of what it generates, and a format learned in context can make the explanation itself less reliable.

Contributions. (1) Evidence from controlled comparisons with four models from two families that a declarative animation format shortens the answer but, with reasoning enabled, neither speeds up generation nor improves reliability, and that the reasons differ between the model families (sections 5 and 6). (2) ExplainSpec, a time-indexed declarative animation format with runtime-provided playback and parameter controls, together with an observation contract that makes free-form and declarative explanations equally inspectable (section 3). (3) A benchmark of 20 explanation tasks with pacing-agnostic checkers, validated by 40 independent reference implementations and mutation testing, and a taxonomy of the errors models make in an in-context-learned declarative language (sections 4 and 5).

References (19)