Papers
Topics
Authors
Recent
Search
2000 character limit reached

Sequence to Sequence Learning

Updated 11 January 2026
  • Sequence to sequence learning is a neural framework that maps variable-length input sequences to output sequences, underpinning applications such as translation and summarization.
  • It utilizes encoder-decoder architectures with attention mechanisms, teacher forcing, and beam search to manage diverse transductive tasks effectively.
  • Recent advances incorporate pretraining, memory augmentation, and optimization strategies to boost generalization, data efficiency, and performance in various benchmarks.

Sequence to sequence learning (seq2seq) is a neural framework that defines a conditional probabilistic model for mapping an input sequence x=(x1,x2,...,xm)x = (x_1, x_2, ..., x_m) to an output sequence y=(y1,y2,...,yn)y = (y_1, y_2, ..., y_n), typically relying on deep neural architectures with trainable parameters. The framework is foundational for tasks such as machine translation, text summarization, parsing, event prediction, image captioning, and speech recognition, and supports general variable-length transductions without restrictive assumptions on the form or alignment of input/output sequences. Canonical implementations are based on encoder-decoder models utilizing recurrent neural networks (RNNs), convolutional neural networks (CNNs), self-attention architectures, or hybridized variants.

1. Formal Model and Core Training Objective

Seq2seq models the conditional distribution P(yx)P(y|x) as a product of autoregressive predictive distributions:

P(yx)  =  t=1nP(yty<t,x)P(y\,|\,x)\;=\;\prod_{t=1}^{n}P\bigl(y_t\mid y_{<t},\,x\bigr)

where y<t=(y1,,yt1)y_{<t}=(y_1,\dots,y_{t-1}). In practice, these conditional probabilities are parameterized by deep networks and estimated by maximizing the cross-entropy log-likelihood (or minimizing its negative):

L(θ)=kt=1n(k)logP(yt(k)y<t(k),x(k);θ)\mathcal{L}(\theta) = -\sum_{k}\sum_{t=1}^{n^{(k)}}\log P\left(y^{(k)}_{t}\mid y^{(k)}_{<t},\,x^{(k)};\theta\right)

Teacher forcing is used during training, feeding the gold token yt1y_{t-1} at each decoding step. At test time, decoding is typically performed by greedy search or beam search for approximate maximization of the score sequence.

2. Model Architectures: Encoders, Decoders, and Attention

The dominant architectural paradigm involves two components:

Encoder: Maps the source sequence xx to a set of continuous representations. Standard implementations include:

  • Bidirectional multi-layer RNN: At time tt, each layer computes both forward and backward hidden states and concatenates them:

ste=[ht(L);  ht(L)]s^e_t = \left[h^{\rightarrow(L)}_t;\;h^{\leftarrow(L)}_t\right]

where LL is the number of layers and t=1,,mt=1,\dots,m. Cells are LSTM or GRU.

  • CNN and Self-Attention Paths: CNNs model local context, self-attention modules (e.g., Transformer, SAN) model global relations. Double-path encoders maintain both and fuse information via gated cross-attention (Song et al., 2018).

Decoder: An autoregressive module that consumes past outputs (or their embeddings) and attends to encoder representations to predict the next token.

  • RNN-based decoder: Conditioned on the previous hidden state and word embedding, optionally attended encoder output.
  • Attention Mechanisms: Soft attention computes normalized alignment scores αi,t\alpha_{i,t} over encoder-derived states, producing context vectors ctc_t, incorporated at each decoding step (Nguyen et al., 2017).
  • Hybrid architectures: Cross-attention modules may combine CNN and SAN features, with learnable gating balancing local/global information (Song et al., 2018).

Initialization schemes beyond the standard start symbol have been shown to improve first word prediction and mitigate error accumulation by explicitly conditioning the first-token prediction on the source context and embedding matrix instead of a fixed start-of-sentence token (Zhu et al., 2016).

Memory-augmented and deep memory-based models (e.g., DeepMemory) further extend architectural depth by stacking memory layers, each constructed via neural read-write operations, subsuming both vanilla encoder-decoder and attention modules as shallow special cases (Meng et al., 2015).

3. Pretraining, Regularization, and Optimization Techniques

Pretraining provides a regularization and optimization advantage, especially in low-resource settings. Notable guidelines:

  • Unsupervised LLM Pretraining: Separate LMs for source and target sides are first trained and their weights (embeddings, first layer, softmax) transferred to the seq2seq model, which is then fine-tuned on parallel data with joint LM and seq2seq objectives. This approach yields substantial BLEU gains and enhances generalization, with maximal gains for combined pretraining of both encoder and decoder plus ongoing LM loss (Ramachandran et al., 2016).
  • Dropout: Applied both between layers and at inputs (e.g., keep probability 0.5), critical for regularization.
  • Adam and AdaDelta Optimizers are widely employed, commonly with mini-batches and learning rate scheduling.
  • Gradient Clipping is used to prevent exploding gradients, typically via 2\ell_2 norm thresholding.
  • Hyperparameter Tuning: Number of layers, embedding size, decoder/encoder state size, and learning rate are tuned based on dev-set BLEU.

Distribution matching frameworks explicitly introduce local latent distributions for each example, modeled via RNN-based “augmenters” that generate paraphrases or similar sequences. The seq2seq model is explicitly trained to align the transformed distribution of augmented source sequences through the decoder to the distribution of augmented targets, optimizing a composite KL divergence objective, improving data efficiency and robustness (Chen et al., 2018).

4. Decoding Methods and Evaluation

Decoding strategies correspond to the inference-time search for the highest scoring output sequence:

  • Greedy search: Fast but susceptible to search errors.
  • Beam search: Maintains KK candidate hypotheses at each step, expands each, and prunes to the top KK.
  • Constrained or Cube-Pruned CKY decoding: For hierarchical/grammar-based seq2seq models, CKY-style dynamic programming is used to traverse the derivation tree and generate the output sequence, enabling compositional and hierarchical translation (Wang et al., 2022).

Model performance is usually measured with BLEU for translation, ROUGE for summarization, and specialized metrics (e.g., paraphrase set match, semantic overlap) for other tasks. BLEU is defined as

BLEU=BPexp(n=1414logpn)\mathrm{BLEU} = \mathrm{BP} \exp\left(\sum_{n=1}^{4} \frac{1}{4} \log p_n \right)

where pnp_n is nn-gram precision, BP is the brevity penalty (Nguyen et al., 2017).

Semantic metrics—such as paraphrase-set accuracy—directly measure whether generated outputs are semantic paraphrases of the gold reference, providing a more faithful evaluation than surface nn-gram scores (Nguyen et al., 2017).

5. Extensions: Memory, Structure, and Compositionality

Seq2seq limitations in compositional generalization have prompted several lines of architectural research:

  • Meta-learning with memory-augmented models. Meta seq2seq frameworks use key–value memories to handle new symbol assignments and to learn rule-templates (e.g., “X twice \to X X”) over episodes, achieving strong compositional generalization on SCAN and related tasks (Lake, 2019).
  • Latent Neural Grammars and Hierarchical Decoders. Tree-structured and phrase-based seq2seq models leverage latent grammars (e.g., QCFG, BTG) to inject bias toward compositional alignment, improving systematicity and few-shot learning (Kim, 2021, Wang et al., 2022).
  • Deep Memory-based sequences. Models such as DeepMemory sequentially apply read-write controllers to build layered sequence representations, approximating high-order feature extraction analogous to deep CNNs in vision, and yielding improvements on long and syntactically-complex sequences (Meng et al., 2015).
  • Sub-task decomposition and intermediate supervision. The computational learning theory of seq2seq with intermediate supervision demonstrates that revealing chained sub-task results at training provably converts intractable multi-hop problems (e.g., bit-parity or multi-step reasoning) into learnable ones for overparametrized RNN and Transformer architectures. Empirically, chain-of-thought and similar prompting protocols reflect this principle (Wies et al., 2022).

6. Limitations and Directions of Current Research

Known limitations of seq2seq frameworks include:

  • Compositional Failures: Standard RNN-based seq2seq architectures fail on systematic generalization splits (e.g. SCAN add-jump, around-right), unlike humans or meta-learned memory-augmented seq2seq (Lake, 2019).
  • Label and Exposure Bias: Locally normalized models suffer from label bias, assign excessive probability to short or partial hypotheses, and experience exposure bias due to mismatch between training and decoding distributions. Beam-Search Optimization (BSO) addresses this by replacing local likelihoods with global scoring functions (Wiseman et al., 2016).
  • Dependence on Monolingual Data: Pretraining methods require large-scale monolingual corpora, limiting immediate applicability to low-resource languages (Ramachandran et al., 2016).
  • Limited Interpretability: Black-box seq2seq models, especially standard flat encoder-decoder architectures, provide little insight into structural alignment or compositional rules, motivating the development of neural grammar-based models and phrase-based CKY decoding (Kim, 2021, Wang et al., 2022).

Prominent themes in current and future research include extending unsupervised pretraining to self-attention architectures, integrating distribution matching with more sophisticated data augmentation, generalizing to non-text modalities, and explicit composition-aware modeling for systematic generalization.

7. Representative Results Across Tasks and Benchmarks

The impact and effectiveness of seq2seq learning have been established across several high-profile tasks:

  • Machine Translation: LSTM-based seq2seq achieved BLEU of 34.8 on WMT’14 English-French, surpassing a strong SMT baseline (33.3) and enabling further improvements via reranking and ensembling (Sutskever et al., 2014). Distribution-matching and double-path models have pushed BLEU further, particularly on long-range and low-resource scenarios (Song et al., 2018, Chen et al., 2018).
  • Event Prediction: Bidirectional, attention-based multi-layer architectures yield BLEU improvements and semantic paraphrase-set accuracy up to ~31% compared to non-attentive or shallow models (Nguyen et al., 2017).
  • Abstractive Summarization: Pretrained seq2seq models attain ROUGE-1 of 32.56 and are strongly preferred in human evaluation over supervised-only baselines (Ramachandran et al., 2016).
  • Compositional Generalization: Memory-augmented meta seq2seq models achieve 99%+ accuracy on SCAN add-jump and around-right, while standard architectures fail catastrophically on these splits (Lake, 2019).
  • Low-Data and Few-Shot: Latent neural grammars and hierarchical phrase-based seq2seq yield significant gains in low-resource and few-shot settings, outperforming vanilla seq2seq by up to 2 BLEU on low-data MT benchmarks (Wang et al., 2022).

The evolution of sequence-to-sequence architectures thus reflects a continual expansion of representational power, data efficiency, and compositional generalization, anchored by rigorous probabilistic modeling and neural parameter sharing.

Topic to Video (Beta)

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 Sequence to Sequence Learning.