arXiv:2509.25475cs.AIcs.LG2025-09

轻量级框架TDHook让复杂模型的可解释性更简单高效。

TDHook: A Lightweight Framework for Interpretability

  • 基于tensordict设计,适配任意PyTorch模型,支持多输入输出场景。
  • 在多目标梯度计算中,速度比Captum快2倍,占用空间仅为transformer_lens一半。
  • 适合计算机视觉、自然语言处理及强化学习中的复杂模型可解释性研究。

深度神经网络的可解释性研究日益重要,尤其在视觉与语言模型领域。然而,图像描述生成或深度强化学习等任务常涉及多输入输出或组合式网络结构,难以直接适配现有可解释性框架。为此,我们提出TDHook——一个开源、轻量、通用的可解释性框架,基于tensordict,适用于任何PyTorch模型。该框架支持归因、探测和灵活干预,可有效处理组合模型,覆盖计算机视觉、自然语言处理、强化学习等多个领域。其依赖极少,磁盘占用约为transformer_lens的一半;在受控基准测试中,运行多目标集成梯度时,无论在CPU还是GPU上,速度均比Captum快约2倍。此外,我们展示了其在计算机视觉、自然语言处理及深度强化学习中的具体应用案例。

原文摘要 · Abstract (English)

Interpretability of Deep Neural Networks (DNNs) is a growing field driven by the study of vision and language models. Yet, some use cases, like image captioning, or domains like Deep Reinforcement Learning (DRL), require complex modelling, with multiple inputs and outputs or use composable and separated networks. As a consequence, they rarely fit natively into the API of popular interpretability frameworks. We thus present TDHook, an open-source, lightweight, generic interpretability framework based on $\texttt{tensordict}$ and applicable to any $\texttt{torch}$ model. It focuses on handling complex composed models which can be trained for Computer Vision, Natural Language Processing, Reinforcement Learning or any other domain. This library features ready-to-use methods for attribution, probing and a flexible get-set API for interventions, and is aiming to bridge the gap between these method classes to make modern interpretability pipelines more accessible. TDHook is designed with minimal dependencies, requiring roughly half as much disk space as $\texttt{transformer_lens}$, and, in our controlled benchmark, achieves up to a $\times$2 speed-up over $\texttt{captum}$ when running integrated gradients for multi-target pipelines on both CPU and GPU. In addition, to value our work, we showcase concrete use cases of our library with composed interpretability pipelines in Computer Vision (CV) and Natural Language Processing (NLP), as well as with complex models in DRL.

可解释性PyTorch轻量框架强化学习

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