Complexity-Aware Evaluation of LLM Comprehension

📄 arXiv: 2609.37405v1 📥 PDF

作者: Ali Mohammadi Esfahani, Nafiseh Kahani, Samuel A. Ajila

分类: cs.SE, cs.AI

发布日期: 2026-09-29


💡 一句话要点

提出复杂性感知框架以评估LLM代码理解能力

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 代码理解 复杂性评估 软件工程 自动化测试 性能分析

📋 核心要点

  1. 现有方法在评估大型语言模型的代码理解能力时,未能充分考虑源代码的结构复杂性,导致准确率的聚合结果可能误导。
  2. 本文提出了一种复杂性感知框架,通过环形复杂度等指标对LLM的代码理解能力进行细致评估,旨在揭示模型在不同复杂性水平下的表现差异。
  3. 实验结果表明,DeepSeek-Coder-V2在自动预测任务中的准确率为78.33%,而Llama为70.33%;随着复杂性增加,准确率显著下降,验证了复杂性感知评估的有效性。

📝 摘要(中文)

大型语言模型(LLMs)在软件工程任务中越来越多地被应用于理解现有源代码,包括行为预测、函数解释、调试和代码审查。然而,聚合基准准确率可能掩盖模型在源代码结构复杂性增加时的可靠性变化。本文提出了一种基于环形复杂度、嵌套深度、分支因子和Halstead体积的复杂性感知框架,以评估LLM的代码理解能力。通过对300个Python函数的自动输入输出预测和对60个函数的手动语义理解评估,研究了DeepSeek-Coder-V2和Llama的表现。结果显示,随着复杂性的增加,模型的准确率显著下降,表明复杂性感知评估提供了比单纯聚合准确率更具诊断性的LLM代码理解可靠性评估。

🔬 方法详解

问题定义:本文旨在解决现有评估方法未能考虑源代码结构复杂性对大型语言模型(LLM)理解能力的影响,导致模型可靠性评估不准确。

核心思路:提出了一种复杂性感知框架,利用环形复杂度、嵌套深度、分支因子和Halstead体积等指标,系统性地评估LLM在不同复杂性水平下的代码理解能力。

技术框架:整体架构包括两个主要模块:自动输入输出预测和手动语义理解评估。首先对300个Python函数进行自动预测,然后对60个函数进行手动评估,按复杂性分组。

关键创新:最重要的创新在于引入复杂性感知评估框架,能够揭示模型在不同复杂性水平下的表现差异,与传统的聚合准确率评估方法本质上不同。

关键设计:在实验中,使用了环形复杂度、嵌套深度、分支因子和Halstead体积作为复杂性指标,设计了相应的评估流程,并通过相关性和逻辑回归分析验证了复杂性与准确率之间的负相关关系。

🖼️ 关键图片

img_0
img_1
img_2

📊 实验亮点

实验结果显示,DeepSeek-Coder-V2在低复杂度下的准确率为93.52%,而在高复杂度下降至52.78%;Llama的准确率从87.04%降至47.22%。这些结果表明,复杂性感知评估显著揭示了模型在不同复杂性水平下的性能差异,验证了该方法的有效性。

🎯 应用场景

该研究的潜在应用领域包括软件工程中的代码审查、调试和自动化测试等任务。通过提供更准确的模型评估方法,能够帮助开发者选择合适的LLM工具,从而提高软件开发效率和代码质量。未来,该框架还可以扩展到其他编程语言和更复杂的代码结构中,进一步提升其应用价值。

📄 摘要(原文)

Large language models (LLMs) are increasingly used for software engineering tasks that require understanding existing source code, including behavior prediction, function explanation, debugging, and code review. However, aggregate benchmark accuracy can conceal how model reliability changes as source code becomes structurally more complex. This paper presents a complexity-aware framework for evaluating LLM code comprehension using cyclomatic complexity, nesting depth, branching factor, and Halstead volume. We evaluate DeepSeek-Coder-V2 and Llama through two complementary tasks: automatic input-output prediction over 300 Python functions and manually assessed semantic comprehension over a balanced subset of 60 functions. The functions are grouped into Low-, Medium-, and High-complexity bands. DeepSeek-Coder-V2 achieves an overall automatic accuracy of 78.33%, compared with 70.33% for Llama. However, accuracy decreases substantially from Low to High complexity, from 93.52% to 52.78% for DeepSeek-Coder-V2 and from 87.04% to 47.22% for Llama. Incorrect predictions are consistently associated with higher values of all four complexity metrics, and correlation and logistic-regression analyses confirm broadly comparable negative associations between structural complexity and correctness. Manual semantic comprehension shows the same degradation pattern, with accuracy decreasing from 100.00% to 75.00% for DeepSeek-Coder-V2 and from 90.00% to 60.00% for Llama. These findings demonstrate that complexity-aware evaluation provides a more diagnostic assessment of LLM code-comprehension reliability than aggregate accuracy alone.