Skip to main content
QUICK REVIEW

[论文解读] Inseq: An Interpretability Toolkit for Sequence Generation Models

Gabriele Sarti, Nils Feldhus|arXiv (Cornell University)|Feb 27, 2023
Topic ModelingComputer Science参考文献 75被引用 7
一句话总结

Inseq 是一个 Python 库,提供可访问且可扩展的序列生成模型可解释性工具, enabling attribution analyses, constrained decoding, and dataset-wide evaluations for decoder-only and encoder-decoder Transformers.

ABSTRACT

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.

研究动机与目标

  • 通过提供一个统一、可扩展的工具包,使序列生成模型(如 MT、代码生成、对话)可解释性民主化。
  • 整合多种特征归因方法(基于梯度、内部特征、扰动)于解码器为主和编码器-解码器 Transformers。
  • 通过可扩展、可重复的工作流,支持实际分析(偏见、知识定位)。
  • 提供用户友好界面(CLI、批处理、可视化)及约束解码,帮助开展鲁棒实验。

提出的方法

  • 提供一个模块化接口,将来自 Transformers 的序列模型与来自 Captum 的归因方法相结合。
  • 支持基于梯度、内部和扰动的归因,包括注意力和 Discretized Integrated Gradients。
  • 包含后处理聚合器,将子词或嵌入层级分数映射到令牌级解释。
  • 实现约束解码和自定义归因目标(如对比输出、不确定性分数)。
  • 提供批处理、聚焦于区间的归因、CLI 访问、JSON 序列化以及可视化,便于可重复分析。
Figure 1: Feature importance and next-step probability extraction and visualization using Inseq with a Transformers causal language model.
Figure 1: Feature importance and next-step probability extraction and visualization using Inseq with a Transformers causal language model.

实验结果

研究问题

  • RQ1统一工具包如何简化并标准化跨序列生成任务的归因分析?
  • RQ2在生成设定下,哪种归因方法对解码器为主和编码器-解码器 Transformers 最为忠实且具信息量?
  • RQ3归因分析能否揭示偏见(如 MT 中的性别偏见)或用高效方法定位大语言模型中的事实知识?
  • RQ4哪些易用性特征(批处理、约束解码、可视化)最适合支持大规模可解释性研究?

主要发现

  • 使用归因方法(IG、Gradients、I×G)和概率度量,展示土耳其语→英语 MT 的性别偏见分析。
  • 显示某些归因分数与职业劳动统计数据之间的相关性,支持在偏见检测中采用对比方法。
  • 引入 Contrastive Attribution Tracing (CAT) 来通过层梯度×激活定位 GPT-2 的事实知识组件,实现高效的知识定位。
  • 为约束解码、基于目标的归因与聚合管道提供实用能力,生成可解释的、令牌级或句子级解释。
  • 验证在大模型上进行归因的 8 位量化兼容性,与全精度相比在归因差异极小。
Figure 2: Computing and visualizing source and target-side attributions using Flan-T5 (Chung et al., 2022 ) .
Figure 2: Computing and visualizing source and target-side attributions using Flan-T5 (Chung et al., 2022 ) .

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。