Papers
Topics
Authors
Recent
Search
2000 character limit reached

TDSE: Dynamic Transformer Sequence Encoding

Updated 6 July 2026
  • TDSE is a dynamic sequence encoding principle that leverages learned positional dynamics or adaptive segmentation to replace fixed token structures.
  • The FLOATER variant uses Neural ODEs to generate continuous-time positional signals, ensuring smooth extrapolation and parameter efficiency in Transformer blocks.
  • TimeSqueeze employs dynamic patching with a state-space model for efficient long-horizon forecasting, reducing computational overhead while preserving temporal details.

Searching arXiv for the cited TDSE/FLOATER and TimeSqueeze papers to ground the article in current records. Transformer Dynamic Sequence Encoder (TDSE) denotes a class of Transformer-compatible sequence encoding mechanisms that replace static, manually fixed sequence representations with adaptive dynamics. In the literature provided here, the term appears in two closely related but non-identical senses. In “Learning to Encode Position for Transformer with Continuous Dynamical Model” (Liu et al., 2020), it refers to FLOATER, a continuous dynamical position encoder in which positional signals are generated by a learned ordinary differential equation. In “TimeSqueeze: Dynamic Patching for Efficient Time Series Forecasting” (Ankireddy et al., 11 Mar 2026), it denotes the dynamic sequence encoding pipeline that combines a state-space encoder, content-aware segmentation, compressed Transformer tokens, and causal unpatching for long-context forecasting. This suggests that TDSE is best understood as a dynamic-sequence-design principle: the sequence representation is learned as a function of underlying dynamics rather than imposed by a fixed sinusoid or a uniform patch grid.

1. Terminological scope and primary variants

The two uses of TDSE share a common objective: to make Transformer sequence handling adaptive while preserving compatibility with standard self-attention. In FLOATER, the adaptive object is the positional signal; in TimeSqueeze, it is the tokenization and compression pattern of the input series. Both formulations are presented as alternatives to fixed design choices that can limit flexibility, extrapolation, or efficiency (Liu et al., 2020, Ankireddy et al., 11 Mar 2026).

Source TDSE object Core mechanism
“Learning to Encode Position for Transformer with Continuous Dynamical Model” (Liu et al., 2020) Positional encoding Learned continuous-time latent trajectory z(t)z(t) via Neural ODE
“TimeSqueeze: Dynamic Patching for Efficient Time Series Forecasting” (Ankireddy et al., 11 Mar 2026) Dynamic sequence compression SSM encoder, thresholded segmentation, compressed Transformer tokens, causal unpatching

In the first formulation, the central problem is that non-recurrent models are permutation equivalent unless position information is explicitly injected, whereas sinusoidal encoding is manually designed and learned position embeddings restrict maximum sequence length. In the second, the central problem is the trade-off between point-wise embeddings, which preserve temporal fidelity but scale poorly, and fixed-length patching, which improves efficiency but can disrupt natural transitions and blur informative local dynamics. The shared theme is not architectural identity, but the replacement of static sequence structure by data-adaptive dynamics.

2. Continuous dynamical position encoding in FLOATER

FLOATER models position encodings as samples from a continuous-time latent trajectory z(t)Rdz(t)\in\mathbb{R}^d governed by a learnable ODE (Liu et al., 2020):

dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),

with equivalent integral form

z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.

The discrete positional encoding for the ii-th token is obtained by sampling this trajectory at positions tit_i, typically with ti=i×Δtt_i = i\times \Delta t, so that ziz(ti)z_i \coloneqq z(t_i). In all experiments, Δt=0.1\Delta t = 0.1. The formulation is explicitly designed so that the encoding can be arbitrarily extrapolated to longer lengths.

Each Transformer block nn maintains its own initial vector z(t)Rdz(t)\in\mathbb{R}^d0, while the same z(t)Rdz(t)\in\mathbb{R}^d1 and therefore the same parameter set z(t)Rdz(t)\in\mathbb{R}^d2 are shared across all blocks. The result is a block-specific trajectory family with shared dynamics and distinct initial conditions. In the “warm-start” setting, these initial states are initialized so that the flow is initially zero and matches a pretrained sinusoidal model.

The vector field z(t)Rdz(t)\in\mathbb{R}^d3 is implemented in all experiments as a two-layer feed-forward network with one nonlinear activation, such as ReLU, between layers. Its input is the concatenation z(t)Rdz(t)\in\mathbb{R}^d4 of dimension z(t)Rdz(t)\in\mathbb{R}^d5, linearly projected to a hidden size z(t)Rdz(t)\in\mathbb{R}^d6, often set equal to z(t)Rdz(t)\in\mathbb{R}^d7, then projected back to z(t)Rdz(t)\in\mathbb{R}^d8. The paper reports about z(t)Rdz(t)\in\mathbb{R}^d9 million extra parameters in dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),0 for the Transformer-Base setting, roughly half the size of a single-layer sinusoidal embedding table of fixed length, and a fraction of the cost of dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),1-sized learned embeddings in every layer. No special regularization was required beyond standard weight-decay and small initial weight scale for dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),2.

A key structural claim is that FLOATER replaces the usual position embedding dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),3 by dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),4, and that adding dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),5 inside query, key, and value projections is equivalent to adding a position-dependent bias inside each self-attention. If the usual query is dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),6, FLOATER uses dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),7 with the same dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),8. Because dz(t)dt=f(t,z(t);θh),\frac{dz(t)}{dt} = f(t, z(t); \theta_h),9 is zero if and only if z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.0 and z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.1, FLOATER strictly contains sinusoidal-only Transformers as a special case.

3. Optimization, numerical integration, and computational profile

FLOATER is trained end-to-end by integrating z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.2 inside the Transformer computational graph, with the overall loss depending on all sampled states z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.3 (Liu et al., 2020). Gradients with respect to z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.4 and z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.5 are computed using the adjoint sensitivity method of Neural ODEs. The description in the paper defines the adjoint z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.6 and backpropagates by solving the augmented ODE

z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.7

backward in time, while accumulating

z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.8

The implementation relies on the publicly available torchdiffeq package. In practice, the ODE is solved on subintervals of length z(t)=z(s)+stf(τ,z(τ);θh)dτ.z(t) = z(s) + \int_s^t f(\tau, z(\tau); \theta_h)\, d\tau.9. For machine translation, a high-order Runge–Kutta solver is used with step size ii0 and therefore five substeps. For GLUE and RACE, the method switches to a simple midpoint rule with the same substep size to reduce overhead.

Several engineering choices are reported for limiting training cost: warm-starting from a pretrained Transformer, initializing ii1 small so the dynamic begins near zero, and caching positional biases for many training iterations when ii2 changes little. These optimizations limit the added training cost to approximately ii3–ii4 relative to a vanilla Transformer, with zero overhead at inference. At inference time, all ii5 may be precomputed up to the maximum needed length at no additional overhead.

The parameter-efficiency argument is explicit. Injecting position signals into every block, as in universal Transformers, usually leads to a per-layer positional cost; FLOATER instead adds only ii6 extra parameters rather than ii7. A full learned embedding matrix of size ii8 per layer would cost ii9, reported as about tit_i0 million parameters for six layers, whereas FLOATER adds only tit_i1 million.

4. Empirical behavior in machine translation and language understanding

The empirical evaluation of FLOATER covers neural machine translation, language understanding, question answering, and ablation against RNN-based alternatives (Liu et al., 2020). On WMT’14 En–De and En–Fr, for both Transformer-Base and Transformer-Large, FLOATER injected at every block raises En–De BLEU by approximately tit_i2–tit_i3 points over fixed sinusoidal encodings and by similar margins over fixed-length learned embeddings. Even when used only at the input layer, it still outperforms baselines by approximately tit_i4–tit_i5 BLEU.

A central result concerns inductive generalization to longer sentences. When training only on sentences shorter than tit_i6 tokens, FLOATER maintains BLEU on much longer sentences up to tit_i7 tokens, whereas sinusoidal and learned embeddings degrade sharply. The reported visualization complements this finding: unlike fixed sinusoidals, described as perfectly smooth, or learned embeddings, described as chaotic for unseen positions, the FLOATER trajectory exhibits smooth, data-adapted curves that generalize to unseen positions without manual design.

On GLUE, with RoBERTa-Base warm-start, FLOATER matches or improves upon tit_i8 of tit_i9 tasks, often by ti=i×Δtt_i = i\times \Delta t0–ti=i×Δtt_i = i\times \Delta t1 points, especially on low-data tasks such as RTE. On RoBERTa-Large, gains of ti=i×Δtt_i = i\times \Delta t2–ti=i×Δtt_i = i\times \Delta t3 points are described as common. On RACE, accuracy improves from ti=i×Δtt_i = i\times \Delta t4 to ti=i×Δtt_i = i\times \Delta t5 on the large model, while SQuAD 1.1 and 2.0 F1/EM are modestly higher or matched.

The RNN ablation is especially relevant to the interpretation of the method. Replacing the flow-based ODE with a ti=i×Δtt_i = i\times \Delta t6- or ti=i×Δtt_i = i\times \Delta t7-layer standard RNN, using either scalar or vectorized inputs, yields strictly lower BLEU, reported as ti=i×Δtt_i = i\times \Delta t8–ti=i×Δtt_i = i\times \Delta t9 versus FLOATER’s ziz(ti)z_i \coloneqq z(t_i)0, for comparable parameter counts. This does not show that recurrent structure is universally ineffective; it shows, more narrowly, that the reported flow-based parameterization is superior to those specific RNN substitutes in the tested setting.

5. TDSE in TimeSqueeze: dynamic patching for time-series forecasting

In TimeSqueeze, TDSE denotes a dynamic patching architecture for time series forecasting rather than a continuous positional ODE (Ankireddy et al., 11 Mar 2026). The high-level pipeline is: input series ziz(ti)z_i \coloneqq z(t_i)1; full-resolution SSM encoding; dynamic patching; Transformer processing on compressed tokens with preserved absolute positions; causal unpatching; SSM decoding and forecasting. The SSM encoder uses Mamba layers and produces point-wise features ziz(ti)z_i \coloneqq z(t_i)2.

The underlying state-space formulation is given as a discretized linear state-space model. With internal state ziz(ti)z_i \coloneqq z(t_i)3 and input ziz(ti)z_i \coloneqq z(t_i)4, the continuous system

ziz(ti)z_i \coloneqq z(t_i)5

is discretized to

ziz(ti)z_i \coloneqq z(t_i)6

The output ziz(ti)z_i \coloneqq z(t_i)7 is then mixed by a point-wise nonlinearity and residual connection to give the embedding ziz(ti)z_i \coloneqq z(t_i)8, and stacking ziz(ti)z_i \coloneqq z(t_i)9 such layers yields Δt=0.1\Delta t = 0.10.

Dynamic segmentation is driven by a local signal-complexity rule. The sliding power estimate over a window of length Δt=0.1\Delta t = 0.11 is

Δt=0.1\Delta t = 0.12

and the complexity score is

Δt=0.1\Delta t = 0.13

A patch boundary is declared at index Δt=0.1\Delta t = 0.14 if

Δt=0.1\Delta t = 0.15

equivalently,

Δt=0.1\Delta t = 0.16

All indices with Δt=0.1\Delta t = 0.17 mark starts of new patches. The description states that this allocates shorter patches in high-variation regions and larger patches in smooth segments.

After segmentation, the boundary sequence is Δt=0.1\Delta t = 0.18. Compressed tokens are formed as Δt=0.1\Delta t = 0.19 for nn0, and the original index nn1 is retained as the absolute position ID. The Transformer backbone, including examples such as an MoE Transformer, processes nn2 together with their absolute position identifiers nn3. Unpatching simply repeats or upsamples each transformed token nn4 across its original patch length nn5, producing nn6 while ensuring causality: the final representation at time nn7 depends only on tokens with original positions less than or equal to nn8.

The complexity analysis is framed in terms of full sequence length nn9 and compressed token count z(t)Rdz(t)\in\mathbb{R}^d00. A point-wise baseline has Transformer complexity approximately z(t)Rdz(t)\in\mathbb{R}^d01 per layer and memory approximately z(t)Rdz(t)\in\mathbb{R}^d02. Fixed-size patching with patch length z(t)Rdz(t)\in\mathbb{R}^d03 yields z(t)Rdz(t)\in\mathbb{R}^d04 and complexity approximately z(t)Rdz(t)\in\mathbb{R}^d05. Dynamic patching yields z(t)Rdz(t)\in\mathbb{R}^d06 tokens and complexity approximately z(t)Rdz(t)\in\mathbb{R}^d07. The token reduction ratio is defined as z(t)Rdz(t)\in\mathbb{R}^d08, empirically reported as about z(t)Rdz(t)\in\mathbb{R}^d09 on pretraining data, implying an attention-cost speedup of approximately z(t)Rdz(t)\in\mathbb{R}^d10, so z(t)Rdz(t)\in\mathbb{R}^d11 corresponds to approximately z(t)Rdz(t)\in\mathbb{R}^d12 smaller quadratic cost.

The reported empirical results emphasize both efficiency and forecasting quality. TimeSqueeze attains up to z(t)Rdz(t)\in\mathbb{R}^d13 faster convergence and z(t)Rdz(t)\in\mathbb{R}^d14 higher data efficiency than equivalent point-token baselines in large-scale pretraining. It reports peak GPU memory reduction of approximately z(t)Rdz(t)\in\mathbb{R}^d15 at z(t)Rdz(t)\in\mathbb{R}^d16 and up to z(t)Rdz(t)\in\mathbb{R}^d17 throughput gain for long forecasting horizons such as horizon z(t)Rdz(t)\in\mathbb{R}^d18. On long-term benchmarks including ETTh1/2, ETTm1/2, and Weather, it matches or slightly outperforms the point-wise Time-MoE model and outperforms fixed-size patching and pure linear encoders by z(t)Rdz(t)\in\mathbb{R}^d19–z(t)Rdz(t)\in\mathbb{R}^d20 in average MSE. The ablations state that dynamic patching is better than fixed patching of size z(t)Rdz(t)\in\mathbb{R}^d21 or z(t)Rdz(t)\in\mathbb{R}^d22 by approximately z(t)Rdz(t)\in\mathbb{R}^d23–z(t)Rdz(t)\in\mathbb{R}^d24 MSE reduction, that the SSM encoder is much better than simple linear embeddings, and that removing fine-grained residuals or absolute position IDs degrades performance by z(t)Rdz(t)\in\mathbb{R}^d25–z(t)Rdz(t)\in\mathbb{R}^d26.

6. Conceptual significance, misconceptions, and limitations

The two TDSE formulations address different failure modes of standard Transformer sequence handling. FLOATER addresses the fact that non-recurrent models are less sensitive to position because position information among input units is not inherently encoded, while TimeSqueeze addresses the inefficiency and representational rigidity of point-wise tokenization and fixed-length patching in long-horizon forecasting (Liu et al., 2020, Ankireddy et al., 11 Mar 2026). The commonality is architectural adaptivity: sequence structure is produced by a learned dynamical process or a content-aware segmentation rule rather than by a fixed table or a uniform patch schedule.

A frequent misconception would be to treat TDSE as synonymous with a learned embedding table. That characterization is inaccurate for both variants. In FLOATER, the encoding is the discretization of a continuous latent trajectory z(t)Rdz(t)\in\mathbb{R}^d27 and can be extrapolated to longer lengths. In TimeSqueeze, the compressed tokens are selected from full-resolution SSM features according to dynamic boundaries, and the original indices z(t)Rdz(t)\in\mathbb{R}^d28 are explicitly preserved as absolute position IDs. Another misconception would be to regard dynamic encoding as eliminating positional structure; in both cases, positional information remains central, but it is modeled dynamically rather than statically.

The limitations are also specific to each instantiation. FLOATER adds approximately z(t)Rdz(t)\in\mathbb{R}^d29–z(t)Rdz(t)\in\mathbb{R}^d30 training overhead relative to a vanilla Transformer, even though inference incurs zero overhead after precomputation. TimeSqueeze requires choosing the threshold z(t)Rdz(t)\in\mathbb{R}^d31 to hit a target compression rate, and it notes possible performance degradation if patches become too coarse in highly volatile signals. Potential extensions named in the TimeSqueeze description include learning boundary placements end-to-end in embedding space rather than thresholding raw z(t)Rdz(t)\in\mathbb{R}^d32, multi-level or hierarchical patching, and extension to irregularly sampled series. For FLOATER, the reported evidence supports three stated desiderata—inductiveness, data-driven flexibility, and parameter efficiency—while the measured gains are consistently described as small but reliable rather than large.

Taken together, these works position TDSE as a research direction rather than a closed recipe. One branch treats positional encoding itself as a dynamical system sampled along sequence index; another treats the input sequence as an object to be dynamically segmented before attention. A plausible implication is that future uses of the term will continue to refer to Transformer encoders in which sequence structure is learned through explicit dynamics, whether those dynamics govern position, segmentation, compression, or their combination.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Transformer Dynamic Sequence Encoder (TDSE).