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 zi≔z(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(n)(0)∈Rdz^{(n)}(0)\in\mathbb{R}^d, while the same ff and therefore the same parameter set θh\theta_h 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 f(t,z;θh)f(t,z;\theta_h) 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][z;t] of dimension d+1d+1, linearly projected to a hidden size hh, often set equal to dd, then projected back to Rd\mathbb{R}^d. The paper reports about $0.53$ million extra parameters in θh\theta_h 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 Lmax⁡L_{\max}-sized learned embeddings in every layer. No special regularization was required beyond standard weight-decay and small initial weight scale for θh\theta_h.

A key structural claim is that FLOATER replaces the usual position embedding pip_i by zi:=z(ti)z_i:=z(t_i), and that adding ziz_i inside query, key, and value projections is equivalent to adding a position-dependent bias inside each self-attention. If the usual query is Wq(xi+pi)+bqW_q(x_i+p_i)+b_q, FLOATER uses Wq(xi+zi)+bqW_q(x_i+z_i)+b_q with the same Wq,bqW_q,b_q. Because ziz_i is zero if and only if f≡0f\equiv 0 and z(0)=0z(0)=0, 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(t) inside the Transformer computational graph, with the overall loss depending on all sampled states zi=z(ti)z_i=z(t_i) (Liu et al., 2020). Gradients with respect to θh\theta_h and z(0)z(0) are computed using the adjoint sensitivity method of Neural ODEs. The description in the paper defines the adjoint a(t)=∂L/∂z(t)a(t)=\partial L/\partial z(t) and backpropagates by solving the augmented ODE

dadt=− a(t)⊤∂f∂z\frac{da}{dt} = -\, a(t)^\top \frac{\partial f}{\partial z}

backward in time, while accumulating

∂L∂θh=−∫a(t)⊤∂f∂θh dt.\frac{\partial L}{\partial \theta_h} = - \int a(t)^\top \frac{\partial f}{\partial \theta_h}\, dt.

The implementation relies on the publicly available torchdiffeq package. In practice, the ODE is solved on subintervals of length Δt=0.1\Delta t=0.1. For machine translation, a high-order Runge–Kutta solver is used with step size Δt/5=0.02\Delta t/5=0.02 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 θh\theta_h small so the dynamic begins near zero, and caching positional biases for many training iterations when ff changes little. These optimizations limit the added training cost to approximately $20$–30%30\% relative to a vanilla Transformer, with zero overhead at inference. At inference time, all ziz_i 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 O(θh)O(\theta_h) extra parameters rather than N⋅Lmax⁡⋅dN\cdot L_{\max}\cdot d. A full learned embedding matrix of size Lmax⁡×dL_{\max}\times d per layer would cost O(N⋅Lmax⁡⋅d)O(N\cdot L_{\max}\cdot d), reported as about $1.6$ million parameters for six layers, whereas FLOATER adds only O(θh)≈0.53O(\theta_h)\approx 0.53 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 $0.4$–$0.8$ 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 $0.3$–$0.6$ BLEU.

A central result concerns inductive generalization to longer sentences. When training only on sentences shorter than $80$ tokens, FLOATER maintains BLEU on much longer sentences up to $140+$ 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 $7$ of $8$ tasks, often by $0.2$–$1.8$ points, especially on low-data tasks such as RTE. On RoBERTa-Large, gains of $0.5$–$1.0$ points are described as common. On RACE, accuracy improves from $82.8$ to $83.3$ 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 $1$- or $2$-layer standard RNN, using either scalar or vectorized inputs, yields strictly lower BLEU, reported as $27.99$–$28.16$ versus FLOATER’s $28.57$, 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 x1,…,xTx_1,\dots,x_T; 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 h1:T∈RT×Dh_{1:T}\in\mathbb{R}^{T\times D}.

The underlying state-space formulation is given as a discretized linear state-space model. With internal state st∈Rns_t\in\mathbb{R}^n and input ut=xtu_t=x_t, the continuous system

ds(t)dt=As(t)+Bu(t),y(t)=Cs(t)+Du(t)\frac{ds(t)}{dt} = A s(t) + B u(t), \qquad y(t) = C s(t) + D u(t)

is discretized to

st=Aˉst−1+Bˉut,ot=Cˉst+Dˉut.s_t = \bar A s_{t-1} + \bar B u_t, \qquad o_t = \bar C s_t + \bar D u_t.

The output oto_t is then mixed by a point-wise nonlinearity and residual connection to give the embedding hth_t, and stacking LL such layers yields h1:Th_{1:T}.

Dynamic segmentation is driven by a local signal-complexity rule. The sliding power estimate over a window of length LL is

Pi=1L∑j=i−Li−1xj2,P_i = \frac{1}{L}\sum_{j=i-L}^{i-1} x_j^2,

and the complexity score is

c(i)=∣xi−xi−1∣Pi.c(i) = \frac{|x_i - x_{i-1}|}{\sqrt{P_i}}.

A patch boundary is declared at index ii if

bi=1  ⟺  c(i)>τ,b_i = 1 \iff c(i) > \tau,

equivalently,

bi={1,∣xi−xi−1∣>τ Pi,0,otherwise.b_i = \begin{cases} 1, & |x_i - x_{i-1}| > \tau\,\sqrt{P_i},\\ 0, & \text{otherwise.} \end{cases}

All indices with bi=1b_i=1 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 p0=1<p1<⋯<pP≤Tp_0=1<p_1<\dots<p_P\leq T. Compressed tokens are formed as zk=hpkz_k=h_{p_k} for k=0…P−1k=0\dots P-1, and the original index pkp_k is retained as the absolute position ID. The Transformer backbone, including examples such as an MoE Transformer, processes z1:Pz_{1:P} together with their absolute position identifiers πpk\pi_{p_k}. Unpatching simply repeats or upsamples each transformed token z~k\tilde z_k across its original patch length ℓk=pk+1−pk\ell_k=p_{k+1}-p_k, producing H~1:T∈RT×D\tilde H_{1:T}\in\mathbb{R}^{T\times D} while ensuring causality: the final representation at time tt depends only on tokens with original positions less than or equal to tt.

The complexity analysis is framed in terms of full sequence length TT and compressed token count PP. A point-wise baseline has Transformer complexity approximately O(T2⋅D)O(T^2\cdot D) per layer and memory approximately O(T2)O(T^2). Fixed-size patching with patch length P0P_0 yields P=⌈T/P0⌉P=\lceil T/P_0\rceil and complexity approximately O(P2⋅D)O(P^2\cdot D). Dynamic patching yields PdynP_{\text{dyn}} tokens and complexity approximately O(Pdyn2⋅D)O(P_{\text{dyn}}^2\cdot D). The token reduction ratio is defined as R=T/PdynR=T/P_{\text{dyn}}, empirically reported as about $4$ on pretraining data, implying an attention-cost speedup of approximately R2R^2, so R=4R=4 corresponds to approximately 16×16\times smaller quadratic cost.

The reported empirical results emphasize both efficiency and forecasting quality. TimeSqueeze attains up to 20×20\times faster convergence and 8×8\times higher data efficiency than equivalent point-token baselines in large-scale pretraining. It reports peak GPU memory reduction of approximately 3.4×3.4\times at (batch,context)=(256,2048)(\text{batch},\text{context})=(256,2048) and up to 10.5×10.5\times throughput gain for long forecasting horizons such as horizon =720=720. 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 $3$–15%15\% in average MSE. The ablations state that dynamic patching is better than fixed patching of size $2$ or $4$ by approximately $20$–30%30\% 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 $3$–6%6\%.

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)z(t) 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 pkp_k 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 $20$–30%30\% training overhead relative to a vanilla Transformer, even though inference incurs zero overhead after precomputation. TimeSqueeze requires choosing the threshold τ\tau 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 xx, 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).