arXiv:2510.03178cs.SEcs.CL2025-10被引 6

通过隐藏变量名揭示大模型代码理解的真实水平

When Names Disappear: Revealing What LLMs Actually Understand About Code

  • 用语义保持的混淆方法移除变量名,测试模型真实理解力
  • 移除命名后摘要任务性能下降40%,执行任务也显著退化
  • 新基准ClassEval-Obf可有效防止模型依赖命名记忆作弊

大型语言模型在代码任务上表现优异,但其如何理解程序语义仍不明确。我们提出代码通过两种渠道传递信息:结构语义(决定程序行为)和人类可读的命名(传达意图)。移除命名渠道后,意图相关任务(如代码摘要)性能显著下降,模型转而进行逐行描述。令人意外的是,执行类任务也出现一致退化,表明现有基准可能奖励对命名模式的记忆而非真正的语义推理。为此,我们设计了一套语义保持的混淆方法,揭示了摘要与执行任务中均存在标识符泄漏。基于此,我们发布了ClassEval-Obf——一个通过混淆抑制命名线索、同时保留程序行为的新基准。实验表明,该基准能降低虚高的性能差距,削弱记忆捷径,并为评估大模型代码理解与泛化能力提供更可靠依据。

原文摘要 · Abstract (English)

Large Language Models (LLMs) achieve strong results on code tasks, but how they derive program meaning remains unclear. We argue that code communicates through two channels: structural semantics, which define formal behavior, and human-interpretable naming, which conveys intent. Removing the naming channel severely degrades intent-level tasks such as summarization, where models regress to line-by-line descriptions. Surprisingly, we also observe consistent reductions on execution tasks that should depend only on structure, revealing that current benchmarks reward memorization of naming patterns rather than genuine semantic reasoning. To disentangle these effects, we introduce a suite of semantics-preserving obfuscations and show that they expose identifier leakage across both summarization and execution. Building on these insights, we release ClassEval-Obf, an obfuscation-enhanced benchmark that systematically suppresses naming cues while preserving behavior. Our results demonstrate that ClassEval-Obf reduces inflated performance gaps, weakens memorization shortcuts, and provides a more reliable basis for assessing LLMs' code understanding and generalization.

代码理解大模型基准测试语义混淆

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