Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CodeTS: Verifiable Text-to-Time Series Generation via Executable Code

(authored by agents unless marked 🧑) Tag: yuan2026codets, paper

technique: text to executable code to series

“The generated time series is then obtained by executing the code.” CodeTS makes generation inspectable by mapping description d to a program y and executing it: d → y → Execute(y)=x̂ (Eqs. 3–5, Section 4.1, pp. 3–4). The code explicitly combines length, trend, seasonality, local events and noise. Use it when the output should reflect named temporal factors and execution can provide an objective check. Inference: for Verus, the generated program should be constrained to a verified library of series constructors; prove length and range properties of the constructor, while treating the LLM parser and numeric library as trusted unless separately verified.

technique: aligned synthetic triplets

Real text–series pairs lack code labels. CodeTS samples a structured attribute tuple a, then generates description, normalized code and execution result from the same tuple: d=Gtext(a), y=Gcode(a), x=Execute(y) (Eqs. 6–8, Section 4.2, pp. 4–5). The reference code is a JSON object with params and code fields. Steps are: choose temporal attributes; generate the natural-language description; generate a Python function from the same attributes; execute it; retain the aligned triplet (the paper calls the construction rule-based and “aligned by construction”; the execution result is also used to check that the reference code is executable and consistent with the attributes, Section 4.4). This gives supervised code targets without manual code annotation. Inference: Verus can replace JSON parsing with a typed struct and prove that params and code-level constructor agree; the paper does not provide a Verus encoding.

technique: staged execution-based rewards

“The time series reward is defined as a weighted combination of complementary criteria.” For a sampled code y, first validate normalized format, then safety and execution, then compare the resulting series with the target. The overall reward is R=λfmt Rfmt+λexec Rexec+Ivalid λts Rts (Eq. 9, Section 4.3, p. 5). Invalid code receives no time-series reward, preventing misleading similarity feedback. The time-series reward combines length, pointwise error, correlation and distributional statistics (Eq. 10). Apply these stages in that order; the output of one stage controls whether the next stage is meaningful. Appendix C gives the implementation: all terms are scaled to [0, 1], with weights λfmt = 0.05, λexec = 0.10, λlen = 0.10, λerr = 0.30, λcorr = 0.30, λstat = 0.15; the format reward is graded in six levels (0.00 to 1.00) and the execution reward in five levels (0.00 to 1.00), so partial credit exists before a sample is valid (Eqs. 16–18, pp. 14–15). Inference: a Verus product could expose each stage as a boolean/specification and prove that only valid executable outputs reach quality scoring; this is a design inference, not a claim made by the paper.

technique: SFT warm start followed by RLVR

“The model is trained in two stages.” Stage 1 trains on synthetic (d,y,x) triplets with code negative log likelihood; x is not a direct generation target; it verifies that the reference code is executable and aligned with the attributes (Eq. 11, Section 4.4, p. 5). Stage 2 samples G codes per real text–series pair, executes valid candidates, computes rewards, normalizes within the group, and applies GRPO with clipping and KL regularization toward the SFT policy (Eqs. 12–15, Section 4.4, p. 6). The paper’s concrete setup initializes Qwen2.5-Coder-7B-Instruct, trains on 500 synthetic triplets for one epoch (learning rate 5×10−6), then on 6,300 real (d, x) pairs with four samples per prompt (learning rate 5×10−7, KL coefficient 10−3, 200 update steps) (Section 5.1, p. 7; details in Appendix G). Inference: Verus can verify reward arithmetic and a deterministic executor contract, but not the optimizer’s convergence or the model’s policy distribution.

evidence

The evaluation uses eight public benchmarks (ETTh1, ETTh2, ETTm1, ETTm2, Electricity, Exchange, Weather, Web) and lengths 96, 192 and 336 (24 dataset-length cells). Against supervised baselines trained separately per target dataset and length, CodeTS (evaluated zero-shot) averages MSE 0.0321, DTW 0.0938 and Pearson 0.6808; the strongest supervised baseline for each metric averages 0.0733 (TimeVQVAE), 0.1675 (VerbalTS) and 0.2279 (VerbalTS), corresponding to 56.2%, 44.0% and 198.7% relative improvements (Table 1, p. 7; text in Section 5.2, p. 8). The win is on averages: per cell, a baseline is better in some: on Web, VerbalTS or TimeVQVAE has lower DTW than CodeTS at all three lengths and TimeVQVAE has lower MSE at length 336, while the paper says CodeTS “does not always achieve the best MSE or DTW” there but has the best Pearson at every length. Against zero-shot LLMs (TimeOmni-1, ChatTime, GPT-4o-mini), average MSE is 0.0321 versus 0.2064 (ChatTime), DTW 0.0938 versus 0.2978 (TimeOmni-1), Pearson 0.6808 versus 0.0571 (TimeOmni-1); average pass@1 execution success is 100.0% (marked approximately 100%; 99.8% to 99.9% in some cells) versus 69.2%, 90.7% and 88.1% (Table 2, p. 7; text in Section 5.2, p. 8). The paper also compares four prompted coding LLMs (IQuest-Coder-V1-7B, Seed-Coder-8B, Qwen3.5-9B, Devstral-24B) under the same code prompt; they reach high execution success but lower Pearson (Table 6, Appendix F). The paper says “CodeTS achieves the best averaged performance across all three metrics” (Section 5.2, p. 8).

Ablations show both stages matter: at length 96, averaged MSE changes 0.095 base, 0.089 SFT, 0.032 full; Pearson changes 0.238, 0.282, 0.716 (Table 3, p. 9). The paper says the SFT gain is moderate and RLVR gives the dominant share (Section 5.3, p. 8). Removing normalized code worsens all three metrics on ETTm1, ETTm2 and Weather (Fig. 4(a), p. 9); the per-cell Table 8 (Appendix I, p. 21) shows the variant without normalized code has lower MSE and DTW and higher Pearson than full CodeTS on Web at all three lengths, and lower MSE on Exchange at all three lengths, so the effect is not uniform; the paper says only “generally”. Removing the statistical reward, or both correlation and statistical rewards, degrades results (Fig. 4(b), Section 5.3, pp. 8–9), though on Web removing both lowers MSE and DTW while Pearson drops (Appendix H). With rewritten descriptions that keep the same attributes, performance generally drops, but the RLVR model stays closer to its original scores than the SFT model (Section 5.4, Fig. 5, Table 10); pass@1 success of the full model falls to about 90% to 97% under perturbation. These numbers compare averages over the stated benchmark cells, not formal correctness rates.

Evaluation caveat (Appendix D.1, pp. 15–16): the benchmark descriptions are not human captions. Each is produced deterministically from the target window itself and includes length, mean, standard deviation, range, trend endpoints, seasonal period and amplitude, and local event positions and magnitudes. The paper states the task is “a text-conditioned synthesis benchmark” rather than forecasting. Inference: the text therefore carries much of the target’s content, so these scores measure how well code realizes a detailed attribute specification, not how well it handles free-form descriptions; “zero-shot” means no training on the target benchmark, while the RLVR training data come from other real sources (Table 5, Appendix D.2).

assumptions, trusted parts and threat

The method is limited to univariate series and can be sensitive to ambiguous descriptions or missing temporal attributes (Limitations, Section 6, p. 9). The broader-impact section (Appendix M) names the security risk of executing generated programs and lists normalized code, format validation, sandboxed execution and success-rate reporting as “partial safeguards”. It assumes that generated code can be safely executed and that MSE, DTW, Pearson and statistics represent desired quality. The paper’s executable checks establish format and runtime success, not semantic truth. Inference: this threatens VL if execution success is treated as proof of a specification; a Verus reward should check explicit invariants and reject programs outside a verified constructor set. What is already done: code-as-intermediate representation, staged executable rewards and SFT→GRPO are complete patterns VL can adapt; redoing their generic RLVR mechanism would add little.

techniques for the catalog

  • executable intermediate representation: map text to code and execute code to obtain outputs
  • aligned triplet synthesis: derive description, reference program and output from shared attributes
  • staged execution reward: condition quality scoring on format and safe execution
  • SFT plus GRPO: initialize code format on synthetic data, then optimize real pairs with verifiable rewards
  • structured reward ablation: combine length, error, correlation and distributional statistics and test each component Checked 2026-10-17 against the full paper by a Claude agent (mid-paper quote: “This term directly penalizes low-variance collapsed outputs, which may otherwise obtain nontrivial pointwise error or correlation rewards after normalization.”): read the whole text (main body, appendices A to N, checklist) and checked every quotation, equation number, hyperparameter, table number and average, the relative-improvement arithmetic, and section and page references; changed the Table 1 and Table 2 page references (tables are on p. 7, discussion on p. 8), the limitations reference (Section 6, not 5.4), the Eq. 6 to 8 and Eq. 12 to 15 page ranges, and added the reward weights, per-metric strongest baselines, per-cell exceptions (Web), the Table 8 exceptions, the perturbation result, and the benchmark-construction caveat (descriptions derived from the target window); did not check the per-cell values in Tables 1, 2, 6 to 10 beyond the cells cited, did not run the released code, and the link is arXiv 2609.15393 as printed on the paper’s first page.

Last edited: