inseq-team/inseq
Interpretability for sequence generation models 🐛 🔍
What it solves
Inseq 是一個工具套件,旨在讓序列生成模型(如大型語言模型與翻譯模型)的事後可解釋性分析更易於使用。它讓使用者能透過將輸出歸因於輸入文字的特定部分,了解模型為何產生特定 token。
How it works
基於 PyTorch 並整合 Hugging Face Transformers,Inseq 提供統一介面以套用各種特徵歸因方法。它支援 encoder‑decoder 模型(ForConditionalGeneration)與 decoder‑only 模型(ForCausalLM)。此工具套件包含多種歸因技術——基於梯度、基於內部結構(注意力)以及基於擾動——並提供在 notebook、瀏覽器或命令列中彙總、篩選與視覺化這些歸因圖的工具。
Who it’s for
主要對象是需要分析生成模型行為、執行對比評估,或在 AI 應用中偵測上下文依賴性的 AI 研究者與開發者。
Highlights
- Broad Model Support: Works with most Hugging Face Transformers generation models.
- Diverse Attribution Methods: Includes saliency, Integrated Gradients, DeepLIFT, LIME, and occlusion.
- Advanced Analysis: Supports contrastive feature attribution and context reliance detection.
- Flexible Visualization: Built-in support for heatmaps in Jupyter Notebooks and HTML exports.
- CLI Tools: Command-line interface for attributing single examples or entire Hugging Face datasets.