arXiv:2511.14465cs.LGcs.AI2025-11中稿 · NeurIPS被引 2

nnterp统一分析Transformer内部机制,支持50+模型变体一键部署。

nnterp: A Standardized Interface for Mechanistic Interpretability of Transformers

  • 基于NNsight封装,自动重命名模块实现跨架构统一接口。
  • 支持16种架构家族、50多个模型变体的干预代码通用部署。
  • 内置常见可解释性方法,可直接访问注意力概率,适合研究者快速验证。

机制可解释性研究需要可靠工具来分析不同架构的Transformer内部结构。当前方法存在根本矛盾:如TransformerLens虽保证接口一致,但需为每种架构手动适配,导致数值偏差;而通过NNsight直接访问HuggingFace模型能保持行为精确,却缺乏跨模型标准化。为此,我们开发了nnterp,一个轻量级包装器,在保留原生HuggingFace实现的基础上提供统一分析接口。通过自动模块重命名和全面验证测试,nnterp使研究人员只需编写一次干预代码,即可在50多个模型变体(覆盖16种架构家族)上部署。该库包含常用可解释性方法(如logit lens、patchscope、activation steering)的内置实现,并支持对支持的模型直接获取注意力概率。通过随库附带的验证测试,研究者可在本地验证自定义模型的兼容性。nnterp弥合了机制可解释性工具中正确性与可用性之间的鸿沟。

原文摘要 · Abstract (English)

Mechanistic interpretability research requires reliable tools for analyzing transformer internals across diverse architectures. Current approaches face a fundamental tradeoff: custom implementations like TransformerLens ensure consistent interfaces but require coding a manual adaptation for each architecture, introducing numerical mismatch with the original models, while direct HuggingFace access through NNsight preserves exact behavior but lacks standardization across models. To bridge this gap, we develop nnterp, a lightweight wrapper around NNsight that provides a unified interface for transformer analysis while preserving original HuggingFace implementations. Through automatic module renaming and comprehensive validation testing, nnterp enables researchers to write intervention code once and deploy it across 50+ model variants spanning 16 architecture families. The library includes built-in implementations of common interpretability methods (logit lens, patchscope, activation steering) and provides direct access to attention probabilities for models that support it. By packaging validation tests with the library, researchers can verify compatibility with custom models locally. nnterp bridges the gap between correctness and usability in mechanistic interpretability tooling.

可解释性Transformer工具包模型分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。