Adjustable Sequence Length in AI Models
- Adjustable Sequence Length (ASL) is a family of methods that treat sequence length as a controllable variable, impacting tasks from speech representation to text generation.
- Techniques include explicit length conditioning, adaptive subsampling, and internal representation probing to tailor model performance to task-specific temporal scales.
- ASL approaches offer practical benefits such as improved computational efficiency, optimal memory utilization, and customized performance across diverse models and applications.
Adjustable Sequence Length (ASL) designates a family of methods in which sequence length is treated as a controllable, adaptive, or explicitly modeled variable rather than a fixed architectural constant. In the literature considered here, “length” can mean pre-training utterance duration in speech SSL, desired output length in conditional generation, latent token count in sequence compression, active context size during long-context inference, or stochastic bitstream length in stochastic-computing neural networks (Gao et al., 2022, Takase et al., 2019, Biermann et al., 2023, Wang et al., 5 Aug 2025). The papers therefore do not instantiate a single canonical ASL algorithm; instead, they show several technically distinct ways of making length first-class in modeling, optimization, and deployment.
1. Scope and terminology
The papers considered here use the phrase in multiple, non-identical ways. In some cases, ASL is direct and explicit: a model is conditioned on a desired output length, or a single model supports a continuous range of compression rates. In other cases, length is implicit: the model learns when to terminate, or a scheduler predicts how many tokens remain. There are also adjacent cases in which the model does not literally resize the sequence, but changes the effective retained context or conditions the network on observed sequence length.
| Interpretation of sequence length | Representative mechanism | Representative paper |
|---|---|---|
| Pre-training utterance duration | Construct corpora with average utterance lengths of 1.1 s, 5.2 s, 10.4 s, and 15.8 s | (Gao et al., 2022) |
| Desired output length | Decoder-side length-aware positional encoding using and | (Takase et al., 2019) |
| Continuous frame period / compression rate | CIF subsampling controlled by | (Chen et al., 2022) |
| Latent sequence length | Query-length-controlled attention or BOS-to-EOS token generation | (Biermann et al., 2023) |
| Layer-wise bitstream length | Per-layer SC sequence configuration | (Wang et al., 5 Aug 2025) |
A recurring terminological caveat is that not every paper using “ASL” refers to adjustable sequence length. In “Adaptive Layer Selection for Layer-Wise Token Pruning in LLM Inference,” ASL explicitly means Adaptive Layer Selection, not adjustable sequence length; the method adapts the layer at which one-shot token selection is performed for KV-cache reduction (Taniguchi et al., 12 Jan 2026). A common misconception is therefore to equate any adaptive context-compression method with ASL in the literal sequence-length sense.
2. Speech and audio: data-side length choice and once-for-all temporal compression
One line of work treats ASL as a data-side control knob in speech SSL. “Match to Win” constructs four wav2vec 2.0 pre-training corpora from the 960 h LibriSpeech corpus, with average utterance lengths of 1.1 s, 5.2 s, 10.4 s, and 15.8 s, while keeping total speech duration fixed at 960 h. The SSL backbone is wav2vec 2.0 base, trained for 300k update steps on 20 V100 GPUs, with an effective batch duration fixed to 1.6 hours of speech per optimization step. In the tested setup, GPU memory utilization and FLOPs both rise sharply with input length: compared with 1 s inputs, 15 s inputs require around , , and more memory at batch sizes 4, 8, and 12, and about higher FLOPs. The downstream results are task-dependent rather than monotonic: 5 s pre-training is best for slot filling and emotion recognition, 10 s for speaker identification, and 15 s for ASR and ASV, with KWS as a partial exception. The paper’s main recommendation is not “shorter is better,” but to match pre-training sequence length to downstream temporal scale whenever possible; if a single universal SSL model is desired, longer-sequence training remains the best setup (Gao et al., 2022).
A second line of work makes the representation length itself adjustable after pre-training. “Once-for-All Sequence Compression for Self-Supervised Speech Models” inserts a CIF-based variable-length subsampling layer after the student CNN feature extractor in DistilHuBERT, and modulates the CIF weights with a continuous control variable . For ,
0
and for 1,
2
At 3, the method recovers vanilla DistilHuBERT; at 4, it reduces to the single-rate CIF model; as 5, it approaches one representation per utterance. With three pre-training ranges, the model covers effective frame periods of 20–90 ms, 20–160 ms, and 20–960 ms. Reported MAC reductions are 68.7% at around 90 ms and 90.6% at around 960 ms, with little overhead from CIF itself. The paper further shows adaptive compression-rate learning by treating 6 as a downstream trainable parameter mapped into the valid range by a Sigmoid; this produces task-specific preferred frame periods without grid search (Chen et al., 2022).
Taken together, these results suggest two distinct speech-ASL paradigms. The first changes what lengths the model sees during representation learning; the second changes the temporal density of the learned representation itself. They address different stages of the pipeline, but both treat length as a task-sensitive operating variable rather than a fixed default.
3. Explicit output-length control in text generation
The most direct output-length-control formulation appears in “Positional Encoding to Control Output Sequence Length.” The paper modifies only the decoder-side positional encoding of a Transformer. In Length-Difference Positional Encoding (LDPE), the decoder encodes remaining budget:
7
In Length-Ratio Positional Encoding (LRPE), it instead encodes relative progress:
8
During training, 9 is set to the gold target length; at inference, it is supplied by the user. The method is continuous rather than lookup-based, so it can handle unseen target lengths. Empirically, LDPE yields near-perfect length control: on Japanese JAMUL, variance is 0.000 at 0, 13, and 26; on English Gigaword, variance is 0.015, 0.012, and 0.013 at 1, 50, and 75. The method also improves ROUGE in multiple settings, and variants with added standard PE indicate that absolute position and length-relative position remain complementary (Takase et al., 2019).
A mechanistic perspective appears in “Length Representations in LLMs.” Rather than introducing an external controller, the paper probes whether instruction-tuned LLMs already encode output-length information internally. Across Llama, Phi, and Qwen families, the strongest signal is consistently found in the second-layer attention output. For example, in Llama-2-7B the second-layer attention output reaches 2 for No-constraint and Length prompts and 0.95 for Priming; similar 0.99 values appear for Llama-2-13B and Llama-2-70B. Single-unit probes show that length is not concentrated in one neuron, but some units are substantially more predictive than others. Intervening on the top-3 units in the second-layer attention output produces directional control: positive scaling yields shorter outputs, and negative scaling yields longer outputs, while scaling the smallest-4 units has little effect. The paper interprets this as evidence that length information is partially disentangled from semantic information and that multi-head attention mechanisms are critical in determining output sequence length (Moon et al., 27 Jul 2025).
These two papers imply different ASL philosophies. The first externalizes length as an explicit decoder-side conditioning signal. The second argues that a length-control mechanism is already present inside the model and can be steered by activation intervention. This suggests that ASL in generation can be either exogenous—through user-specified length variables—or endogenous—through internal length representations.
4. Sequence compression, tokenization, and effective context reduction
Sequence compression work often sits at the boundary between direct ASL and adjacent effective-length control. “Harnessing Attention Mechanisms: Efficient Sequence Reduction using Attention-based Autoencoders” makes the dependence of attention output length on query count explicit. With
5
the number of output tokens becomes 6, not 7. This allows an encoder to map a sequence of length 8 to a latent sequence of arbitrary chosen length 9. The method shows that 0 is near-perfect and 1 remains over 90% accurate, but it is not train-once/use-any-length ASL: the scaling matrix hard-wires both input length and latent length, the model requires static input shape, and different compression ratios require different parameterizations (Biermann et al., 2023).
PairAlign makes length a learned symbolic decision rather than a byproduct of frame stride. Given 2, the autoregressive tokenizer defines
3
starts from BOS, and terminates with EOS. Length is thus determined by decoder behavior rather than by local VQ assignment. Teacher generation and inference impose a hard cap
4
which stabilizes termination but does not provide a fully user-facing continuous rate knob. On TIMIT retrieval, PairAlign reduces total archive tokens from 800,611 to 360,723, average tokens per segment from 84.62 to 38.13, and symbolic bitrate from 253.89 bit/s to 114.39 bit/s, corresponding to a 54.94% token reduction and 5 compression. On a continuous-sweep probe, mean sequence length falls from 85.08 to 25.48 and adjacent length change 6 from 7 to 8, indicating better length stability under 100 ms shifts (Banerjee et al., 7 May 2026).
Long-context inference work often adjusts the effective attended sequence rather than literal sequence length. ESA partitions prior tokens into initial 9, middle 0, and local 1 regions, selects only the top-2 middle tokens 3, and computes
4
The token-selection scores are approximated with compressed query-key vectors, reducing dimensionality from 5 to 6. The paper gives a reduction ratio
7
and reports that complexity is reduced to up to 1.56% of full attention in each step. ESA supports contexts up to 256k and is especially strong on multiple-retrieval benchmarks such as Counting-Stars and NeedleBench, where token-level selection preserves dispersed evidence better than chunk-level selection (Wang et al., 20 Feb 2025).
A useful distinction emerges here. PairAlign learns variable output length; the attention autoencoder fixes a chosen latent length per model instance; ESA preserves a long raw input but reduces the effective attended context. All three alter the sequence budget, but only the first is a direct learned variable-length tokenizer.
5. Adaptive decoding, optimization, and scheduling
ASL also appears in inference-time adaptive computation. In dLLM-ASR, length is anchored by a lightweight ASR prior rather than by an arbitrary fixed denoising canvas. The model initializes denoising from a CTC-based prior, uses that prior as a reference for generation length, prunes high-confidence padding tokens to tighten the active sequence, and skips denoising for tokens whose confidence exceeds a threshold 8. The default values are 9 and fallback 0. Relative to Whisper-LLaDA, which uses a fixed generation length of 128 tokens, dLLM-ASR improves average WER from 6.51 to 6.34 and average RTF from 1.736 to 0.063, a reported 27.6× RTF reduction. Relative to autoregressive Whisper-LLaMA3, it delivers a 4.44× speedup in average RTF while maintaining comparable WER. The method is not arbitrary user-controlled length generation; it is prior-anchored, ASR-specific adaptive effective sequence-length reduction (Tian et al., 25 Jan 2026).
At the optimization level, FSPO addresses a pathology of sequence-level RL: fixed clipping of the whole-sequence importance ratio systematically reweights short and long responses. The paper formalizes this with Length Reweighting Error (LRE) and proposes clipping in sequence log-IS space with a KL-corrected drift term and 1-scaled width:
2
Here 3 is estimated from average negative per-token KL, and the 4 factor is motivated by the asymptotic Gaussian scaling of sequence log-ratios. Empirically, FSPO reduces LRE to 0.037, compared with 0.162 for RLOO and 0.264 for GSPO, flattens clip rates across length bins, stabilizes training, and improves downstream performance (Mao et al., 11 Sep 2025).
A complementary systems problem is simply predicting how long generation will be. “Predicting LLM Output Length via Entropy-Guided Representations” reuses the main model’s hidden states rather than an auxiliary predictor. EGTP computes next-token entropy
5
converts it to weights with a softmax, and pools prompt hidden states into a single representation. PLP then predicts remaining length during decoding from the prompt representation and generated-token hidden states. On ForeLen, EGTP reduces MAE by 29.16% over the best baseline; in the RL scenario, PLP improves MAE from 95.24 to 80.85. When integrated with a length-aware scheduler, the method yields throughput 131.05 and padding ratio 0.18 on Long Sequence, and throughput 194.21 and padding ratio 0.09 on Reasoning. Its overhead on Qwen2.5-7B is 0.67 ms and 7.21 MB (Xie et al., 12 Feb 2026).
These papers indicate that deployment-oriented ASL frequently depends on adaptive pruning, fair optimization across lengths, or accurate residual-length forecasting, even when the base model is not directly instructed to produce a target length.
6. Hardware-level ASL in stochastic computing
In stochastic-computing neural networks, “sequence length” refers to bitstream length, not token count. “Energy-Efficient Stochastic Computing (SC) Neural Networks for Internet of Things Devices With Layer-Wise Adjustable Sequence Length (ASL)” defines ASL as a layer-wise mixed-precision scheme in which different SC layers use different stochastic sequence lengths:
6
Longer bitstreams improve precision; shorter bitstreams reduce cycles, latency, and energy. The paper models truncation noise propagation with operator norms and accumulated amplification factors
7
showing that early-layer truncation is amplified much more strongly than late-layer truncation. Empirically, the first two layers contribute more than 80% of inference-accuracy importance in the RF sensitivity analysis, and the theoretical and RF-derived importance rankings agree on early-layer dominance (Wang et al., 5 Aug 2025).
The proposed deployment strategies are a coarse-grained rule, 8, and task-specific fine-grained search. For 6-layer networks with 9, the coarse configuration is 0. On a 32 nm, 1 GHz, pipelined SC MLP, fine-grained ASL on Fashion-MNIST achieves energy 3.83 mJ, accuracy loss 0.083%, energy saving 49.83%, and latency saving 64.94% relative to the fixed-length 1 baseline. Similar savings are reported on SVHN and CIFAR10, and the paper summarizes the best cases as over 60% savings in energy/latency overheads with negligible accuracy loss (Wang et al., 5 Aug 2025).
This hardware interpretation is conceptually distant from output-length control, but it preserves the central ASL principle: sequence length is no longer globally uniform and can be allocated where it matters most.
7. Broader sequence analytics, length-aware conditioning, and common misconceptions
Outside generation and speech, some work treats sequence length as a conditioning signal rather than something to resize directly. LAIN for CTR prediction keeps a fixed maximum input length of 1000, but conditions the model on observed behavior length 2 through a Spectral Length Encoder, Length-Conditioned Prompting, and Length-Modulated Attention. The latter adjusts attention sharpness with
3
Across DIN, DIEN, SIM, SDIM, and TWIN on three real-world benchmarks, LAIN reports gains up to 1.15% AUC and 2.25% LogLoss reduction, with less than 1.5% additional parameters and about 2.3% inference time overhead. The paper is explicit that this is not per-user dynamic truncation; it is length-aware adaptive modeling (Zhang et al., 27 Jan 2026).
Variable-length sequence analytics has an older systems formulation in time-series mining. “Effective and Efficient Variable-Length Data Series Analytics” replaces the assumption of a predefined subsequence length with direct support for a range 4. ULISSE provides variable-length subsequence matching through master series, shared PAA prefixes, and iSAX envelope indexing, while MAD/VALMOD incrementally discovers motifs and discords across all lengths in a range. The paper reports that these methods are up to orders of magnitude faster than alternatives, and that MAD is up to one order of magnitude faster than DAD for Top-1 5 discord discovery (Linardi, 2020).
A final misconception concerns the boundary between ASL and adjacent effective-context methods. One-shot KV-pruning with adaptive layer choice can compress the retained context to budget 6 and improve decoding complexity, but this is not the same as literal adjustable sequence length. In the paper that names this method ASL, the acronym means Adaptive Layer Selection; the adaptive decision is primarily when to prune, not what target sequence length to generate (Taniguchi et al., 12 Jan 2026).
Taken together, these results suggest that ASL is best understood as a design space rather than a single technique. Length can be a user-specified output budget, a learned internal variable, a pre-training corpus property, a latent compression rate, an active context budget, a scheduler forecast target, or a hardware precision allocation. The unifying theme is not the mechanics, but the replacement of fixed-length assumptions with explicit length-aware control or adaptation.