[Paper Review] Inseq: An Interpretability Toolkit for Sequence Generation Models
Inseq is a Python library that provides accessible and extensible interpretability tools for sequence generation models, enabling attribution analyses, constrained decoding, and dataset-wide evaluations for decoder-only and encoder-decoder Transformers.
Past work in natural language processing interpretability focused mainly on popular classification tasks while largely overlooking generation settings, partly due to a lack of dedicated tools. In this work, we introduce Inseq, a Python library to democratize access to interpretability analyses of sequence generation models. Inseq enables intuitive and optimized extraction of models' internal information and feature importance scores for popular decoder-only and encoder-decoder Transformers architectures. We showcase its potential by adopting it to highlight gender biases in machine translation models and locate factual knowledge inside GPT-2. Thanks to its extensible interface supporting cutting-edge techniques such as contrastive feature attribution, Inseq can drive future advances in explainable natural language generation, centralizing good practices and enabling fair and reproducible model evaluations.
Motivation & Objective
- Democratize interpretability for sequence generation models (e.g., MT, code synthesis, dialogue) by providing a unified, extensible toolkit.
- Consolidate multiple feature attribution methods (gradient-based, internals-based, perturbation-based) for decoder-only and encoder-decoder Transformers.
- Support practical analyses (bias, knowledge localization) with scalable, reproducible workflows.
- Offer user-friendly interfaces (CLI, batching, visualization) and constrained decoding to enable robust experimentation.
Proposed method
- Provide a modular interface combining sequence models from Transformers with attribution methods from Captum.
- Support gradient-, internals-, and perturbation-based attribution, including attention and Discretized Integrated Gradients.
- Include post-processing aggregators to map subword or embedding-level scores to token-level explanations.
- Enable constrained decoding and custom attribution targets (e.g., contrastive outputs, uncertainty scores).
- Offer batching, span-focused attribution, CLI access, JSON serialization, and visualizations for reproducible analyses.

Experimental results
Research questions
- RQ1How can a unified toolkit simplify and standardize attribution analyses across sequence generation tasks?
- RQ2Which attribution methods are most faithful and informative for decoder-only and encoder-decoder transformers in generation settings?
- RQ3Can attribution analyses reveal biases (e.g., gender bias in MT) or locate factual knowledge in large language models using efficient techniques?
- RQ4What usability features (batching, constrained decoding, visualization) best support large-scale interpretability studies?
Key findings
- Demonstrates gender bias analysis in Turkish→English MT using attribution methods (IG, Gradients, I×G) and probability metrics.
- Shows correlation between certain attribution scores and labor statistics for occupations, supporting contrastive approaches in bias detection.
- Introduces Contrastive Attribution Tracing (CAT) to locate factual knowledge components in GPT-2 via layer-gradient×activation, achieving efficient knowledge localization.
- Offers practical capabilities for constrained decoding, target-based attribution, and aggregation pipelines to produce interpretable, token- or sentence-level explanations.
- Validates 8-bit quantization compatibility for attribution on large models with minimal attribution differences versus full precision.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.