TL;DR
Large Language Models (LLMs) struggle with time-series data due to a fundamental modality mismatch between raw numbers and text. This paper introduces Time-Series-to-Structured-Program (T2SP), a deterministic, training-free method that decomposes time series into trends, periods, and events expressed as code-like symbolic programs. By aligning time-series data with the code and text modalities LLMs excel at, T2SP significantly boosts performance, slashes inference latency, and scales gracefully to long sequences.
What Problem Does This Paper Address?
While LLMs excel at complex reasoning and instruction-following, time-series analysis remains a major blind spot. Currently, researchers try to bridge this gap in three ways: serializing raw numbers into long strings (e.g., [0.1962, 0.2121, ...]), rendering data as visual plots for Vision-Language Models (VLMs), or fine-tuning models directly on temporal data.
However, these approaches force the LLM to do the heavy lifting of inferring high-level temporal structures value-by-value or pixel-by-pixel. This creates a severe representation mismatch, leading to massive tokenization overhead, format failures on long sequences, and an inability to capture fine-grained localized anomalies.
Methods
Instead of changing the model, the authors propose changing the representation. T2SP is a deterministic, training-free, and fully invertible pipeline that translates a raw time-series signal into a structured, human- and machine-readable program.
The pipeline breaks down a time series into four interpretable components:
- Trend ($\tau$): Modeled using smooth, locally adaptive B-spline functions to capture the overall trajectory.
- Periods ($\pi_k$): Extracted using Fourier spectrum analysis to identify dominant frequencies and fit global or piecewise sinusoids.
- Events ($\epsilon_j$): Isolated from the remaining signal using mathematical primitives like Spikes (for instantaneous shocks) and Gaussian events (for smooth, localized bumps).
- Residuals ($r$): Parameterized as Gaussian noise or preserved as raw values depending on whether exact reconstruction is required.
These components are formatted into a clean, program-like syntax (e.g., BSplineTrend(...), Sinusoid(...)). Because the decomposition is additive ($x = \tau + \sum \pi_k + \sum \epsilon_j + r$), it is fully invertible. An LLM can modify the text program, and T2SP can perfectly reconstruct the edited program back into a raw time-series array.
Datasets
The authors evaluated T2SP across three core tasks—editing, captioning, and question answering—using several datasets:
- TSEdit: A new synthetic benchmark introduced in this paper. It pairs time series with free-form natural language editing instructions (e.g., "Flatten the trend" or "Remove the anomaly at t=50") along with ground-truth edited series.
- ETTh1: A real-world electricity transformer oil temperature dataset used for human evaluation of complex, ambiguous editing requests.
- Wafer & ECG200: Standard UCR time-series classification datasets used to evaluate the quality of generated captions via downstream classification accuracy.
- TSQA, TRQA, and ETI: Existing multiple-choice benchmarks testing structural pattern recognition and explanation matching.
Key Insights and Ideas
- Leveraging Pretraining Code Corpora: LLMs are natively trained on massive amounts of source code. Representing a time series as a structured program allows the model to leverage its existing code-parsing and symbolic reasoning capabilities rather than guessing patterns from raw numbers.
- Component Isolation: In time-series editing, traditional models struggle with the trade-off between fidelity (making the requested change) and preservation (leaving everything else untouched). Because T2SP isolates components into distinct lines of code, the LLM can delete a single spike event without corrupting the underlying trend or periodic cycles.
- Algorithmic Efficiency over Model Scale: Shifting the burden of feature extraction from the neural network to a deterministic mathematical pipeline eliminates the need for expensive fine-tuning or complex agentic loops.
Key Results
T2SP was tested against raw string and vision baselines across multiple LLMs (including GPT-5.4, Claude-haiku-4.5, Gemini-3.1-flash-lite, and Qwen-3.5-9B).
- Superior Editing Performance: On the TSEdit benchmark, T2SP consistently achieved the highest edit fidelity and format success rates. For instance, using GPT-5.4, T2SP achieved an average fidelity score of 0.907 compared to 0.753 for raw strings and 0.493 for vision.
- Human Preference: In blind pairwise evaluations on real-world ETTh1 data, human annotators overwhelmingly preferred T2SP's edits over raw strings (up to an 84.4% win rate) and vision baselines (up to a 92.9% win rate).
- Graceful Scaling: As sequence lengths scaled up to 4096 points, raw string and vision baselines suffered from exponential increases in runtime and format failure rates. T2SP remained completely stable in both processing time and success rate.
Limitations and Future Work
The primary limitation of T2SP is its reliance on a general trend-period-event decomposition framework. While highly effective for many applications, this abstraction may not fit specialized domains. For example, electrocardiogram (ECG) signals are characterized by highly specific morphological primitives (P, Q, R, S, and T waves) where relative timing and precise shapes carry clinical meaning that global trends or simple sinusoids cannot capture.
The authors note that designing domain-specific symbolic decompositions tailored to these unique primitives is a promising direction for future work.
Summary updated