TL;DR
InstructTime introduces natural language instructions to the task of time series editing, moving away from rigid, hardcoded attribute vectors. By aligning text and time series data into a shared multi-modal latent space via contrastive learning, it allows users to perform fine-grained modifications and continuously control the intensity of the edit through simple vector interpolation.
What Problem Does This Paper Address?
Time Series Editing (TSE) aims to modify specific properties of an existing time series (like adding a medical anomaly to a healthy heart rate signal) while preserving all its other underlying characteristics.
Prior state-of-the-art TSE methods suffer from two major limitations:
- Rigid Formatting: They rely on predefined, hardcoded attribute vectors (e.g.,
[Variability=High, Bradycardia=No]). This requires tedious feature engineering and prevents users from leveraging unstructured, real-world text like clinical nurse notes or patient narratives. - All-or-Nothing Edits: Existing diffusion-based editors rely on stochastic sampling to generate edits. They lack a mechanism to control the strength or severity of the modification, making it impossible to smoothly transition an attribute from mild to severe.
Methods
The authors present InstructTime, the first instruction-based time series editor. Its architecture consists of three main components:
- Multi-Resolution Time Series Encoder ($E_\phi$): To capture both global trends (like seasonality) and localized anomalies (like sudden spikes), this encoder uses $k$ parallel 1D Convolutional Neural Networks (CNNs) with varying kernel sizes.
- Instruction Encoder ($E_\theta$): Text instructions are first processed by a frozen, pretrained text embedding model. The resulting vector is passed through $k$ parallel Multi-Layer Perceptrons (MLPs) to create a chunked representation that directly maps to the multi-resolution segments of the time series encoder.
- Transformer-Based Decoder ($\Psi$): This component takes the aligned embeddings and models their intra- and inter-modality relationships using a self-attention mechanism to output the edited time series.
Controllable Editing via Interpolation
Instead of using a diffusion process, InstructTime maps both modalities onto a shared unit-length hypersphere using a CLIP-style contrastive loss (InfoNCE) paired with a mean squared error reconstruction loss. Because the latent space is geometrically continuous, the authors introduce a simple linear interpolation mechanism:
$$z_w = \frac{(1 - w) z_x + w z_c}{\|(1 - w) z_x + w z_c\|}$$
By varying the interpolation weight $w$ from $0$ to $1$, users can smoothly dial up the editing strength from pure reconstruction ($w=0$) to complete conditional generation ($w=1$).
Datasets
The model was evaluated across three distinct benchmarks:
- Synthetic Dataset: 18,000 generated time series containing combinations of five multi-resolution attributes: trend direction, trend type, seasonality, abrupt mean shifts, and noise levels.
- Air Quality Dataset: 3,684 particulate matter ($PM_{2.5}$) records from Beijing and London, categorized by location and season.
- NICU Heart Rate Dataset: A newly introduced real-world dataset containing 36,679 infant heart rate records (length 300) labeled with clinical attributes: heart rate variability and bradycardia events.
Key Insights and Ideas
- Resolution-Wise Semantic Alignment: By chunking both the text and time series embeddings into $k$ segments, the contrastive loss forces specific phrases in an instruction to align with their corresponding temporal scale (e.g., matching the word "abrupt" to a small-kernel CNN segment that detects local shifts).
- Latent Space Continuity: Rather than relying on stochastic diffusion steps, treating editing as a path traversal on a hypersphere provides stable, deterministic control over how an edit manifests.
- Few-Shot Recalibration: When faced with entirely unseen conditions, the model can be rapidly adapted using a two-step few-shot tuning procedure. It uses the base model to generate synthetic pairs, which are then used to "re-calibrate" the geometric positioning of the new text prompt relative to known concepts on the hypersphere.
Key Results
InstructTime establishes a new state-of-the-art for time series editing under natural language conditions:
- Higher Fidelity & Better Preservation: On the synthetic dataset, InstructTime achieved a significantly higher Log Ratio of Target-to-Source (RaTS) score of 6.87 (indicating successful editing) and a near-zero preservation error ($|RaTS| = 0.02$), outperforming diffusion-based alternatives like TEdit and TimeWeaver.
- Smooth Transitions: Qualitative evaluations show that increasing the interpolation weight $w$ successfully increases the slope of trends or the severity of drops without altering the background noise or seasonality patterns.
- Robust Generalization: InstructTime demonstrated strong zero-shot performance when tested against unseen paraphrases generated by GPT-4o, maintaining stable editability metrics.
Limitations and Future Work
The authors note that InstructTime struggles to edit local variability (Gaussian-like noise magnitude) as effectively as diffusion models, which naturally excel at modeling stochastic noise distributions.
To address this, future work includes exploring variational architectures to better handle stochastic properties, extending the framework to support step-wise sequential instructions, and testing the model directly on raw, un-templated clinical text.
Summary updated