Sequence

A sequence is an ordered list of tokens, symbols, events, frames, residues, or measurements. Text, protein sequences, genome segments, time series, audio frames, and action traces can all be represented as sequences, but they do not share the same semantics.

A generic sequence is:

where is sequence length and is the item at position .

Conditional Modeling

Autoregressive sequence modeling factorizes a joint distribution into conditionals:

Masked or denoising sequence modeling predicts hidden positions from context:

where is the masked index set.

Important Axes

  • Alphabet: byte, subword, amino acid, nucleotide, event type, or continuous token.
  • Length: short fixed sequence, long document, long genome region, or streaming signal.
  • Directionality: causal, bidirectional, local-window, or global context.
  • Alignment: positions may correspond across modalities, homologs, frames, or timestamps.
  • Structure: sequences may imply graph, geometry, hierarchy, or repeated motifs.

Representation Contract

A sequence representation should state how raw symbols become model input:

where defines alphabet, vocabulary, segmentation, truncation, padding, masking, and special tokens. may differ from the raw length .

DomainToken UnitPosition MeaningMain Risk
textbyte, character, subword, worddocument orderchunking and context-window truncation
proteinamino acid, residue token, domain segmentresidue index, chain, insertion codehomolog leakage and residue-index mismatch
genomebase, k-mer, region token, variant-centered windowcoordinate system and strandoverlapping windows and assembly mismatch
time seriesevent, frame, measurement windowtimestamp or sampling orderirregular sampling and future leakage
action traceaction, observation, tool callexecution orderhidden state and environment mismatch

Positional Information

Sequence models need a convention for position:

where is a token embedding and is a positional encoding. Position may be absolute, relative, rotary, temporal, residue-indexed, or genomic-coordinate-based. The choice changes extrapolation and alignment behavior.

Masking and Padding

For variable-length sequences, define valid positions:

Losses and metrics should ignore padding:

This is critical for documents, proteins, genomes, audio frames, and batched action traces. Averaging per token and per sequence can support different claims.

Split Risks

  • Text: near-duplicate documents, copied passages, or shared source collections.
  • Protein: homologous sequences, same family, same structure template, or MSA leakage.
  • Genome: overlapping windows, same locus, same chromosome region, or annotation-source leakage.
  • Time series: future information, overlapping windows, or subject/session leakage.
  • Agent traces: same task template, hidden tool state, or evaluator leakage.

Checks

  • What does one token represent?
  • Is position absolute, relative, periodic, temporal, or biologically indexed?
  • Can the model see future positions?
  • Is truncation removing the important signal?
  • Are near-duplicate or homologous sequences split across train and test?
  • Are padding and masked positions excluded from loss and metrics?
  • Does the tokenization preserve the entity mapping needed for labels?