---
title: Instruction-based Time Series Editing
url: https://www.emergentmind.com/topics/instruction-based-time-series-editing
type: topic
---

# Instruction-based Time Series Editing

Instruction-based time series editing is the task of taking an existing time series and an instruction describing new conditions, then generating a modified series that satisfies the requested change while preserving the original structure as much as possible. In its explicit natural-language form, the task is formalized as learning a function $\hat{\mathbf{x}} = f_\theta(\mathbf{x}, \mathbf{c})$, where $\mathbf{x}$ is the input series and $\mathbf{c}$ is a textual instruction; the output should realize the target condition without unnecessarily altering non-target properties [2508.01504]. Closely related formulations include diffusion-driven editing under point-wise and segment-level constraints, as in CocktailEdit, and instruction-conditioned in-context editing in which the “instruction” is given by structured demonstrations rather than natural language [2506.05276] [2603.22586].

## 1. Definition and problem scope

Time series editing differs from ordinary generation, forecasting, and imputation because it starts from an existing trajectory and seeks a controlled counterfactual variant rather than a wholly new sample or a reconstruction of what actually happened. The central requirement is selective modification: some properties should change, while others and the instance-specific idiosyncrasies should remain similar to the source. In the formal definition used by InstructTime, the goal is to transform $\mathbf{x} \in \mathbb{R}^T$ into $\hat{\mathbf{x}}$ under a natural-language instruction $\mathbf{c} = [c_1,\dots,c_L]$, with the model inferring the original condition from $\mathbf{x}$ itself rather than receiving an original attribute vector as input [2508.01504].

The application scenarios described for this task are explicitly counterfactual and “what-if” in character. Physiological signals are a canonical example: a neonatal ICU heart-rate trace may be edited so that a normal record acquires a plausible early bradycardia event while retaining patient-specific variability. Other examples include changing the city or season condition for weekly PM2.5 trajectories, or editing synthetic sequences to alter trend direction, seasonality, abrupt mean shifts, or noise level [2508.01504].

Within the broader time-series literature, time series editing combines conditional generation, counterfactual reasoning, and per-instance preservation. Forecasting generates future values from history; imputation fills missing values; anomaly detection identifies unusual segments; unconditional generation samples new trajectories; time series editing instead modifies an already observed trajectory under alternate conditions. The diffusion-oriented framing of Time Series Editing (TSE) emphasizes this difference by defining editing as precise modification under local and segment-level constraints while preserving temporal coherence [2506.05276].

## 2. From attribute-conditioned diffusion editing to instruction-based editing

A major precursor to instruction-based editing is attribute-conditioned diffusion editing. Recent editors such as TimeWeaver and TEdit are described as conditional diffusion models that typically consume an input time series, an original attribute vector, and a target attribute vector. TEdit extends TimeWeaver into an editing framework that denoises toward a target-conditioned series while remaining close to the learned data distribution [2508.01504].

The principal criticism of that design is twofold. First, conditions are represented as rigid, predefined attribute vectors: the attribute space must be manually enumerated, future edits must remain expressible in that fixed space, and nuanced real text cannot be used directly. Second, editing is “all-or-nothing” through sampling: the diffusion sampler runs under the target condition, but there is no explicit continuous control over editing strength; variation arises through stochastic sampling rather than a dedicated edit-intensity parameter [2508.01504].

CocktailEdit addresses a different limitation of diffusion editing: insufficient control granularity. It introduces a framework that combines confidence-weighted anchor control for point-wise constraints with classifier-based control for statistical properties such as sums and averages over segments. These controls are applied during denoising inference, are intended to maintain temporal coherence, and are designed to integrate seamlessly with conditionally trained diffusion-based time-series models. The stated aim is simultaneous, flexible control across different constraint types for human-in-the-loop time series generation and editing [2506.05276].

Taken together, these two lines of work define two complementary notions of “instruction.” In the InstructTime formulation, the instruction is free-form text describing target conditions. In the CocktailEdit formulation, the effective instruction is a structured set of point-wise and segment-level controls. The walkthrough associated with CocktailEdit further presents it as a foundation for instruction-based editing by mapping user requests into anchors, confidence masks, and segment constraints; this suggests a backend architecture in which natural language or UI actions are translated into diffusion-time controls rather than directly decoded from text [2506.05276].

## 3. InstructTime architecture

InstructTime is introduced as the first instruction-based time series editor. Its architecture has three components: a multi-resolution time-series encoder $\mathcal{E}_\phi$, an instruction encoder $\mathcal{E}_\theta$, and a conditional time-series decoder $\Psi$. These define a unit-norm time-series embedding $\mathbf{z}_x = \mathcal{E}_\phi(\mathbf{x})$, a unit-norm instruction embedding $\mathbf{z}_c = \mathcal{E}_\theta(\mathbf{c})$, and a decoder output $\hat{\mathbf{x}} = \Psi(\mathbf{z}_x,\mathbf{z}_c)$ [2508.01504].

The time-series encoder is explicitly multi-resolution. It uses $k$ parallel 1D CNN branches, each with kernel size proportional to $T$; in the reported experiments, $k=8$, with kernel sizes corresponding to the fractions $1$, $\frac{2}{3}$, $\frac{1}{2}$, $\frac{1}{3}$, $\frac{1}{4}$, $\frac{1}{6}$, $\frac{1}{8}$, and $\frac{1}{10}$ of the sequence length. Large kernels are intended to capture global structure such as trend and seasonality, whereas small kernels target local structure such as abrupt shifts, local variability, and events. The branch outputs are concatenated into a $D=k\cdot d$ dimensional representation and normalized to lie on a unit-radius hypersphere [2508.01504].

The instruction encoder aligns text with that same hyperspherical space. A frozen pretrained sentence embedding model encodes the instruction; the default implementation uses SentenceTransformer `paraphrase-mpnet-base-v2`, while `all-mpnet-base-v2` and `roberta-base-nli-mean-tokens` are also evaluated. The resulting sentence embedding is passed through $k$ parallel MLPs, each producing one chunk of the final embedding, so that the text representation is decomposed resolution by resolution in the same manner as the time-series representation [2508.01504].

A shared multimodal representation space is then learned by a CLIP-style symmetric InfoNCE loss. Matching time-series/instruction pairs are pulled together, and mismatched pairs are pushed apart. Reconstruction is learned with an MSE loss through the decoder, and training proceeds in two stages: first contrastive alignment only, then joint optimization of contrastive and reconstruction losses. The reconstruction term is weighted relative to the contrastive term via a parameterization using $\gamma$, with the default setting $\gamma = 1$, corresponding to a reconstruction contribution of approximately $10^{-1}$ relative to contrastive [2508.01504].

The decoder treats the time-series and instruction embeddings as a sequence of two tokens, applies positional encoding, and passes them through a Transformer-style stack of 8 self-attention blocks with feedforward and residual connections. The hidden state associated with the time-series token is projected by a linear head to the full output sequence. This design is intended to support inter-modality interaction while allowing information from different temporal resolutions to mix inside the transformer [2508.01504].

## 4. Editing strength, local–global control, and instruction modalities

The defining mechanism for controllable editing in InstructTime is linear interpolation in the shared embedding space:
\[
\mathbf{z}_w = (1-w)\mathbf{z}_x + w\mathbf{z}_c, \quad w \in [0,1],
\]
followed by decoding
\[
\hat{\mathbf{x}}_w = \Psi(\mathbf{z}_w,\mathbf{z}_c).
\]
At $w=0$, the model reconstructs the input; at $w=1$, it generates a series purely from the instruction; intermediate values yield partial edits that interpolate between the original instance and the target condition [2508.01504].

This interpolation is presented as the solution to the “all-or-nothing” limitation of prior diffusion-based editors. The reported behavior is a deterministic, monotonic progression of edit strength controlled by a single scalar $w$. In the synthetic experiments, as $w$ increases from 0 to 1, a flat trend becomes mildly upward and then strongly upward, while seasonality and mean-shift patterns remain preserved over a broad range of intermediate values. Quantitatively, $\Delta\mathrm{DTW}$ becomes more negative as $w$ increases, RaTS increases for edited attributes, and $|\mathrm{RaTS}|$ for preserved attributes remains small for low to moderate $w$ before growing near $w=1$ [2508.01504].

Local and global edits are handled primarily through the multi-resolution design. Global attributes such as trend, seasonality, and noise level are associated with larger receptive fields, whereas local attributes such as abrupt mean shifts and bradycardia episodes are associated with smaller receptive fields. The text embedding is chunked accordingly, and the transformer jointly processes all chunks. At the same time, the model has no explicit mask or explicit temporal localization mechanism; instructions of the form “add an event at 5 minutes” are not handled through direct indexing, and localization is instead implicit in the learned representation [2508.01504].

A distinct but related instruction modality appears in the foundation-model line represented by iAmTime. There, the instruction is not natural language but a structured prompt built from example episodes and a query. The prompt serializes targets, covariates, histories, and futures using semantic tokens such as `[START]`, `[TARGET_SERIES]`, `[EXOG]`, `[MID]`, `[FUTURE_EXOG]`, and `[END]`, and the model infers the task from demonstrated input–output mappings rather than textual descriptions. The same framework covers forecasting, imputation, reconstruction, anomaly correction, classification, and source de-mixing, so that editing becomes an in-context transformation learned from examples [2603.22586].

The comparison between these modalities is technically consequential. InstructTime offers explicit natural-language conditioning and a scalar control parameter $w$. iAmTime offers structured, example-based instructions and non-autoregressive quantile outputs over edited futures. CocktailEdit, by contrast, offers direct constraint enforcement through denoising-time controls. These are different operationalizations of instruction-based editing rather than interchangeable implementations [2508.01504] [2603.22586] [2506.05276].

## 5. Datasets, metrics, and empirical results

The empirical evaluation of InstructTime spans three datasets. The synthetic benchmark contains 18,000 univariate time series of length $T=200$, generated from combinations of 5 trend types, 2 seasonality levels, 3 abrupt mean-shift levels, and 2 local-variability levels, giving $5 \times 2 \times 3 \times 2 = 60$ attribute combinations with 300 samples each. The air-quality benchmark contains 3,684 weekly PM2.5 series of length $T=168$, with attributes city and season. The NICU heart-rate benchmark contains 36,679 series of length $T=300$, with attributes heart-rate variability and bradycardia events [2508.01504].

Evaluation separates editability from preservability. The principal metrics are RaTS, the log ratio of target-to-source classifier probabilities,
\[
\mathrm{RaTS}(\hat{\mathbf{x}}, \mathbf{x}, \tilde{c}) =
\log\left(\frac{p(\tilde{c}\mid \hat{\mathbf{x}})}{p(\tilde{c}\mid \mathbf{x})}\right),
\]
and $\Delta\mathrm{DTW}$, which measures whether the edited output is closer than the source to real series from the target attribute configuration. Higher RaTS is desirable for edited attributes, lower $|\mathrm{RaTS}|$ is desirable for preserved attributes, and more negative $\Delta\mathrm{DTW}$ indicates stronger movement toward the target distribution. On synthetic data, MSE and MAE are additionally reported against synthetic ground truth [2508.01504].

| Dataset | InstructTime results in the instruction-based setting | Notes |
|---|---|---|
| Synthetic | $\Delta \text{DTW}=-14.62$, RaTS $=6.87$, $|\text{RaTS}|=0.02$, MSE $=2.26$, MAE $=1.18$ | Best reported setting among compared methods |
| Air quality | $\Delta \text{DTW}=-1.84$, RaTS $=0.51$, $|\text{RaTS}|=0.62$ | Other methods have positive $\Delta \text{DTW}$ |
| NICU heart rate | $\Delta \text{DTW}=-4.38$, RaTS $=0.18$, $|\text{RaTS}|=0.42$ | Lower preserved-attribute error than baselines |

These results are reported against instruction-adapted versions of TimeWeaver and TEdit, where the baselines replace attribute vectors with embeddings from the same sentence encoder used in InstructTime. In the instruction-based setting, InstructTime is reported as achieving stronger editability and markedly better preservability, especially on synthetic data where $|\mathrm{RaTS}|=0.02$ indicates minimal disruption to preserved attributes [2508.01504].

Generalization is evaluated in two distinct senses. For unseen phrasings of known conditions, 50 paraphrases per attribute level are generated with GPT-4o, with 70% used for training and 30% held out. In this setting, InstructTime maintains strong performance; on the synthetic dataset it achieves $\Delta\text{DTW}=-14.26$, RaTS $=5.62$, and $|\text{RaTS}|=0.16$. For entirely unseen attribute levels, zero-shot editing is weak, but few-shot tuning with even one real example is reported to improve editability substantially, and larger numbers of examples bring performance close to a model trained on all levels [2508.01504].

The ablation studies identify several architectural and optimization dependencies. Values $\gamma \in \{0,1\}$ give similar good results, whereas $\gamma=2$ harms RaTS and $|\mathrm{RaTS}|$ on synthetic and NICU data. Small numbers of resolutions are insufficient, with $k=2$ underperforming on synthetic and NICU data, and $k \in \{6,8\}$ providing the best balance. Among pretrained text encoders, Paraphrase MPNet is best on the synthetic dataset with long instructions describing four attributes, MPNet is better than RoBERTa on short instructions, and RoBERTa yields poorer preservability [2508.01504].

## 6. Related directions, misconceptions, limitations, and future work

One common misconception is that “instruction-based” necessarily implies natural-language prompts. The literature described here supports at least three distinct instruction channels. InstructTime uses free-form text. CocktailEdit uses structured constraints, notably point-wise anchors and segment-level statistical controls. iAmTime uses example-based instructions encoded by demonstrations and semantic tokens. The term therefore refers less to a specific modality than to conditioning editing on externally specified target behavior [2508.01504] [2506.05276] [2603.22586].

A second misconception is that instruction-based editing automatically provides exact temporal localization. InstructTime does not include an explicit temporal mask or index-based mechanism; its handling of locality is implicit through multi-resolution representations. CocktailEdit is closer to explicit localization because it directly supports point-wise and segment-level controls during denoising. iAmTime’s localization is likewise structural: the prompt format specifies which parts of examples and queries serve as inputs, outputs, targets, and covariates, but it does not provide natural-language temporal grounding [2508.01504] [2506.05276] [2603.22586].

The limitations reported across these works are correspondingly different. InstructTime may struggle with complex or ambiguous real-world text, lacks explicit support for instructions such as “add an event at 5 minutes,” is currently evaluated on univariate and moderate-length sequences, and appears weaker than diffusion methods on pure noise attributes such as local variability [2508.01504]. CocktailEdit acknowledges a trade-off between control precision and distribution preservation, noting that “obvious distribution drift still exists” under strong guidance [2506.05276]. iAmTime does not take natural language, does not explicitly enforce exact constraints such as mass conservation, and depends on prompt construction and pretraining coverage for behavior under novel domains [2603.22586].

The future directions identified in the source material are technically specific. For InstructTime, proposed directions include variational extensions such as hyperspherical VAEs, step-wise editing for sequential instructions, integration with foundation models, deployment on real multimodal time-series-plus-text corpora, and bidirectional use of the shared embedding space for text generation from time series [2508.01504]. For CocktailEdit, future work is framed around improving the control-precision versus distribution-preservation trade-off and developing more advanced control mechanisms [2506.05276]. For example-based instruction-conditioned foundation models, the implied directions include richer instruction modalities, broader task coverage, improved example selection and prompt construction, and tighter integration of user-specified constraints into decoding [2603.22586].

Instruction-based time series editing therefore comprises a family of methods rather than a single architecture. In its natural-language form, it is exemplified by InstructTime’s shared multimodal embedding space, multi-resolution encoding, and interpolation-based control of edit strength. In its constraint-based form, it appears as diffusion-time control over anchors and segment statistics. In its demonstration-based form, it becomes in-context editing through structured prompts and example-conditioned decoding. The common objective across these variants is selective transformation of a given trajectory under externally specified conditions, with preservation of temporal coherence and non-target structure as the central technical constraint [2508.01504] [2506.05276] [2603.22586].

Source: https://www.emergentmind.com/topics/instruction-based-time-series-editing