Debugging Sequence-to-Sequence Models with Seq2Seq-Vis

Hendrik Strobelt, Sebastian Gehrmann, Michael Behrisch, Adam Perer, Hanspeter Pfister, Alexander M. Rush

Abstract

Neural sequence-to-sequence (seq2seq) models are powerful but notoriously difficult to debug due to their high-dimensional internal states. This paper presents SEQ2SEQ-VIS, an interactive visual analysis tool designed to open the "black box" of these models. By decomposing the translation process into identifiable stages—representation, alignment, and decoding—the tool enables researchers to trace errors back to specific components. Key features include nearest-neighbor lookups in the training data and a "what-if" engine for counterfactual testing. We demonstrate the tool's effectiveness by diagnosing a search-level failure in a German-to-English translation model.

Introduction: The "Black Box" Problem in Seq2Seq Models

Neural attention-based seq2seq models are the state-of-the-art for tasks like machine translation. However, their complexity makes them prone to opaque failures. When a model produces an incorrect or nonsensical output, it is often unclear whether the fault lies with the encoder's representation, the attention mechanism's alignment, or the beam search algorithm's pruning. SEQ2SEQ-VIS addresses this by providing a human-interpretable interface to attribute errors to specific parts of the pipeline.

Methods: The SEQ2SEQ-VIS Framework

The tool is integrated with the OpenNMT library and facilitates three primary debugging workflows:

  1. Visualizing Pipeline Stages: Users can examine every step, from encoder hidden states to the final beam search tree.
  2. Connecting to Training Data: The "Neighborhood View" performs nearest-neighbor lookups in the vector space, showing training examples that produced similar internal representations to help identify if the model is drawing on relevant patterns.
  3. Counterfactual Testing: A "what-if" engine allows users to manually override model decisions—such as forcing a specific word or adjusting attention weights—to observe how the sequence evolves.

Results: Case Study: Diagnosing the 'Dunkel' Error

The authors demonstrate the tool using a German-to-English model trained on the IWSLT ’14 dataset. In one instance, the model failed to translate the word dunkel (dark). Using SEQ2SEQ-VIS, the researchers systematically ruled out potential causes:

  • The Encoder: The Neighborhood View showed dunkel was surrounded by correctly used training examples, suggesting the representation was sound.
  • The Attention: The Attention Vis confirmed a strong connection between the source word and the generated output.
  • The Search: The TopK List revealed that "dark" had a high probability but was narrowly beaten by a competitor and subsequently pruned by the beam search.
The SEQ2SEQ-VIS interface showing the Translation View, Neighborhood View, and the 'what-if' analysis for the word 'dark'.

By forcing the word "dark" into the sequence using the tool's interactive interface, the model immediately generated the correct full translation. This confirmed that the error was a search failure rather than a fundamental learning deficiency.

Conclusion

SEQ2SEQ-VIS transforms model debugging from guesswork into a systematic diagnostic process. By categorizing errors into representation, alignment, and decoding buckets, practitioners can gain actionable insights into model behavior. While currently a manual tool, future work aims to automate feedback loops for model fine-tuning and scale these insights to global dataset behaviors.

Summary updated

BibTeX
@inproceedings{strobelt2018debugging,
  author = {Hendrik Strobelt and Sebastian Gehrmann and Michael Behrisch and Adam Perer and Hanspeter Pfister and Alexander M. Rush},
  title = {{Debugging Sequence-to-Sequence Models with Seq2Seq-Vis}},
  booktitle = {BlackboxNLP @ EMNLP},
  year = {2018},
  doi = {10.18653/v1/w18-5451},
}
Figure