Abstract
Encoder-decoder networks are popular for modeling sequences probabilistically in many applications. These models use the power of the Long Short-Term Memory (LSTM) architecture to capture the full dependence among variables, unlike earlier models like CRFs that typically assumed conditional independence among non-adjacent variables. However, in practice, encoder-decoder models exhibit a bias towards short sequences that surprisingly gets worse with increasing beam size. In this paper, we show that such a phenomenon is due to a discrepancy between the full sequence margin and the per-element margin enforced by the locally conditioned training objective of an encoder-decoder model. The discrepancy more adversely impacts long sequences, explaining the bias towards predicting short sequences. For the case where the predicted sequences come from a closed set, we show that a globally conditioned model alleviates the above problems of encoder-decoder models. From a practical point of view, our proposed model also eliminates the need for a beam-search during inference, which reduces to an efficient dot-product based search in a vector-space.
Introduction
Neural encoder-decoder (ED) models, typically utilizing LSTM architectures, have become the standard for sequence generation tasks. Despite their power, they suffer from a persistent "length bias," where the model systematically assigns higher probabilities to shorter, often generic, sequences. This issue is highlighted by the "beam search paradox": while increasing beam width should theoretically find more optimal sequences, it often leads to lower accuracy in ED models by uncovering short, high-probability sequences that the local training objective failed to penalize.
This paper identifies the root cause as a mathematical "margin discrepancy" and proposes a globally conditioned Encoder-Encoder (EE) model to address these failures in closed-set applications like chat suggestions or "Smart Reply."
The Margin Discrepancy and Length Bias
The core issue lies in the locally conditioned maximum likelihood objective. ED models optimize for a local margin—the probability of the next correct token relative to others at a specific step. However, because sequence probabilities are multiplicative, the total probability of a correct sequence decays as it grows longer.
In conversational data, high entropy (many valid ways to respond) acts as a "tax" on long sequences. Even if the model is confident at each step, the cumulative noise makes a long, correct response appear less likely than a short, incorrect one. Analysis shows that in 98% of ED failures, the correct sequence actually had a lower total probability than the incorrect one, proving the issue is the model's distribution rather than the search algorithm.
Proposed Method: Globally Conditioned Encoder-Encoder
To eliminate length bias, the authors propose a Globally Conditioned Encoder-Encoder (EE) model. Instead of step-by-step decoding, this architecture uses two separate RNN encoders:
- Dual Encoders: An input encoder ($x$) produces vector $v_x$, and a candidate encoder ($y$) produces vector $v_y$ for the entire output sequence.
- Global Scoring: The compatibility of a pair is calculated via a simple dot-product $v_x \cdot v_y$.
- Global Normalization: The model is normalized over the entire sequence space using importance sampling with negative examples during training, rather than normalizing at every token.
For tasks with a fixed "whitelist" of allowed responses, inference is transformed into a Maximum Inner Product Search (MIPS). This is significantly faster than iterative beam search and avoids the computational overhead of standard decoders.
Evaluation and Results
The model was evaluated on the Open Subtitles (319M utterances) and Reddit Comments (501M comments) datasets. Key findings include:
- Length Robustness: The EE model significantly outperformed the ED model as sequence length increased. While ED Recall@5 dropped to nearly zero for sequences longer than 8 tokens, the EE model maintained steady performance.
- Calibration: The EE model produced better-calibrated probabilities across varying sequence lengths.
- Efficiency: By replacing beam search with dot-product search, the EE model is highly optimized for production environments.
Conclusion
The proposed globally conditioned Encoder-Encoder model effectively resolves the length bias inherent in standard locally conditioned decoders. While currently restricted to closed-set tasks (where outputs are selected from a whitelist), it offers a more theoretically sound and computationally efficient approach for sequence selection. Future work may explore hybrid models where an ED system generates candidates for re-ranking by an EE model.
Summary updated