Seq2Seq-Vis: A Visual Debugging Tool for Sequence-to-Sequence Models

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

Abstract

Neural Sequence-to-Sequence models have proven to be accurate and robust for many sequence prediction tasks, and have become the standard approach for automatic translation of text. The models work in a five stage blackbox process that involves encoding a source sequence to a vector space and then decoding out to a new target sequence. This process is now standard, but like many deep learning methods remains quite difficult to understand or debug. In this work, we present a visual analysis tool that allows interaction with a trained sequence-to-sequence model through each stage of the translation process. The aim is to identify which patterns have been learned and to detect model errors. We demonstrate the utility of our tool through several real-world large-scale sequence-to-sequence use cases.

Introduction

Neural sequence-to-sequence (seq2seq) models are the backbone of modern machine translation and text summarization. However, their internal operations are often treated as a "black box." When a model fails—such as translating "good morning" into "attack them"—developers often lack the tools to trace the error back to its source. The challenge lies in the high-dimensional latent states that drive these models; a 512-dimensional vector is impossible for a human to interpret without context.

The Five Stages of Seq2Seq

To make these models interpretable, the authors decompose the seq2seq pipeline into five distinct stages: Encoder (S1), Decoder (S2), Attention (S3), Prediction (S4), and Beam Search (S5). Understanding the flow of information between these stages is critical for identifying where a model's logic diverges from human expectations.

The five stages of the seq2seq pipeline.

The Seq2Seq-Vis Interface

Seq2Seq-Vis provides an interactive environment to probe these five stages through several coordinated views:

  1. Translation View: This view displays the high-level decision chain. It uses bipartite graphs to show Attention weights and bar charts to visualize the Top-K word predictions at each step.
  2. Neighborhood View: This is a core innovation of the tool. It allows users to ground abstract latent vectors by searching a database of training samples for the "nearest neighbors" in vector space. By seeing which training examples produced similar internal states, researchers can infer what the model "thinks" it is doing.
  3. State Trajectories: By projecting high-dimensional hidden states into 2D space (using t-SNE), the tool visualizes the model's path through a sentence. This helps identify geometric patterns, such as loops that lead to repetitive text generation.
  4. Interactive Probing: Users can perform counterfactual analysis by manually forcing the model to select specific words or re-directing attention weights to see how the final output changes.
The Seq2Seq-Vis interactive interface.

Key Insights and Case Studies

The utility of Seq2Seq-Vis was demonstrated across several benchmarks, including IWSLT ’14, WMT ’14, and Gigaword. Several key insights emerged:

  • Grounding Decisions: The Neighborhood View connects abstract decisions to concrete training samples, making the model's internal logic tangible.
  • Beam Search Bottlenecks: The tool revealed that models often assign high probability to the correct word, but the beam search algorithm prunes it too early. Visualizing these "near misses" allows for better tuning of search parameters.
  • Visualizing Model Loops: Under-trained models often get stuck in repetitive cycles. In the trajectory view, these appear as literal geometric loops, providing a clear visual signature of this failure mode.
  • Attention as Look-ahead: The tool shows that attention isn't just for alignment; models often "look ahead" to future words (like verbs at the end of German sentences) long before they are translated.

In one case study involving a German-to-English translation, the tool showed that a mistranslation occurred because a narrow beam search (K=5) missed the word "dark," despite the model assigning it high probability. In another, the authors corrected a date-conversion error by manually re-directing attention from the letter 'y' in "May" to the letters 'r' and 'c' in "March."

Conclusion

Seq2Seq-Vis provides a powerful framework for cracking open the seq2seq black box. By grounding latent states in training data and allowing for interactive probing, it enables a more rigorous approach to debugging and understanding deep learning models. Future work will focus on improving projection accuracy and extending the tool to other sequence modalities like audio and video.

Summary updated

BibTeX
@article{strobelt2018seq,
  author = {Hendrik Strobelt and Sebastian Gehrmann and Michael Behrisch and Adam Perer and Hanspeter Pfister and Alexander M. Rush},
  title = {{Seq2Seq-Vis: A Visual Debugging Tool for Sequence-to-Sequence Models}},
  journal = {IEEE Trans. Vis. Comput. Graph.},
  year = {2018},
  doi = {10.1109/tvcg.2018.2865044},
}
Figure