让大模型生成代码时的每一步决策都可解释,支持交互式调试。
TokenScope: Token-Level Explainability and Interpretability for Code-Oriented Tasks in Large Language Models

- 通过解码时信号与语法树分析,实时展示代码生成中的注意力和结构信息。
- 支持替换令牌、反事实分支探索,可动态测试不同生成路径。
- 适合开发者调试模型错误代码或研究代码生成机制。
大型语言模型(LLM)在代码生成过程中进行的词元级决策理解仍是一大挑战。尽管现有工具能提供模型内部或生成结果的洞察,但通常缺乏解码时信号、细粒度不确定性度量以及探索替代生成路径的交互机制。我们提出 TokenScope,一个针对基于解码器的 LLM 的交互式可解释性与分析工具,可在生成过程中暴露词元级指标、注意力模式与结构信息。TokenScope 支持交互式词元替换、反事实分支与基于抽象语法树的代码感知聚合。通过融合解码时信号与结构化程序分析,使对 LLM 代码生成行为的系统性研究成为可能。
原文摘要 · Abstract (English)
Understanding how Large Language Models (LLMs) make token-level decisions during code generation remains a major challenge for both researchers and practitioners. While recent tools provide insights into model internals or generation outcomes, they often lack decoding-time signals, fine-grained uncertainty measures, and interactive mechanisms for exploring alternative generation paths. We present TokenScope, an interactive interpretability and analysis tool for decoder-based LLMs that exposes token-level metrics, attention patterns, and structural information during generation. TokenScope supports interactive token replacement, counterfactual branching, and code-aware aggregation via abstract syntax trees. By unifying decoding-time signals with structural program analysis, TokenScope enables systematic investigation of LLM behaviour during code generation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。