CodeTS generates and verifies time series from text using executable code
CodeTS: Verifiable Text-to-Time Series Generation via Executable Code
Machine LearningArtificial Intelligence
Summary
Generating time-based data from written descriptions is useful but hard to control properly. The authors introduce CodeTS, a method that first turns text descriptions into computer code, which explicitly shows how to create the time series data. This code can then be run to produce accurate and verifiable time series. They teach CodeTS by making it practice with structured examples and improve it by rewarding outputs that are correct and high quality. Their tests show CodeTS outperforms other methods in creating time series directly from text.
What this means in practice
- •For data engineers: Generate customizable time series data for testing models when real data is limited or unavailable.
- •For financial analysts: Create scenario-specific financial time series by describing desired market behaviors in text to simulate rare or hypothetical events.
Authors
Xudong Yuan, Shunyu Liu, Tongya Zheng, Huiping Zhuang, Mingli Song, Kaixuan Chen
Abstract
Text-to-Time Series Generation (Text-to-TS) provides a promising paradigm for synthesizing time series from natural language, enabling scenario-specific generation when real observations are scarce or costly to acquire. However, existing methods typically lack an explicit mechanism for deriving generation logic from textual descriptions to guide time series synthesis. In this paper, we propose CodeTS, a verifiable framework that uses code as an intermediate generation interface, reformulating Text-to-TS generation as a Text-to-Code-to-TS process. CodeTS first maps textual temporal descriptions into an explicit code space, where executable code specifies how textual requirements shape target temporal patterns, and then obtains the time series through code execution. To learn this code generation process reliably without real code annotations, CodeTS constructs aligned Text-Code-TS triplets from structured temporal attributes for supervised initialization. More importantly, we further design multi-stage execution-based rewards that verify format validity, code executability, and time series quality, enabling real Text-TS pairs to provide training signals for Reinforcement Learning with Verifiable Rewards (RLVR). Extensive experiments on eight benchmarks across short, medium, and long generation lengths demonstrate that CodeTS provides a strong zero-shot solution for Text-to-TS generation, outperforming LLM-based baselines and achieving better averaged results than supervised generative baselines trained on the target datasets.