Code complexity metrics such as cyclomatic complexity have long been used to assess software quality and maintainability. With the rapid advancement of large language models (LLMs) on code understanding and generation tasks, an important yet underexplored question arises: do these traditional complexity metrics meaningfully characterize the difficulty LLMs experience when processing code? In this work, we empirically demonstrate that, after controlling for code length, classical metrics exhibit no consistent correlation with LLM performance, revealing a fundamental mismatch with model-perceived difficulty. To address this gap, we propose LM-CC, a novel code complexity metric designed from the perspective of LLMs. The core premise of LM-CC is that LLM-perceived difficulty is driven by the nonlinearity of program semantics. Accordingly, we decompose programs into semantic units based on entropy, organize these units into a compositional hierarchy, and quantify complexity as a principled aggregation of compositional level and branching-induced divergence, capturing cumulative model uncertainty during code processing. Our extensive experiments show that LM-CC not only correlates more strongly with LLM performance than traditional metrics but also that lowering it directly enhances task performance.


翻译:长期以来,诸如圈复杂度等代码复杂度度量指标一直被用于评估软件质量与可维护性。随着大型语言模型(LLMs)在代码理解与生成任务上的快速发展,一个重要但尚未被充分探索的问题随之产生:这些传统的复杂度度量指标能否有效表征LLMs在处理代码时所感受到的难度?在本工作中,我们通过实证研究表明,在控制代码长度后,经典度量指标与LLM性能之间不存在一致的关联,揭示了其与模型感知难度之间的根本性错配。为弥补这一差距,我们提出了LM-CC,一种从LLM视角设计的新型代码复杂度度量指标。LM-CC的核心前提是:LLM感知的难度由程序语义的非线性所驱动。据此,我们将程序基于熵分解为语义单元,将这些单元组织成一个组合层次结构,并将复杂度量化为组合层级与分支引发的发散度的原则性聚合,从而捕捉代码处理过程中累积的模型不确定性。我们的大量实验表明,LM-CC不仅比传统指标与LLM性能的相关性更强,而且降低该复杂度能直接提升任务性能。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
结合知识增强的大型语言模型复杂问题求解综述
专知会员服务
16+阅读 · 2025年5月7日
重新思考不确定性:大语言模型时代的关键综述与分析
专知会员服务
39+阅读 · 2024年11月20日
《大语言模型的数据合成与增强综述》
专知会员服务
43+阅读 · 2024年10月19日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
《大型语言模型持续学习》综述
专知会员服务
93+阅读 · 2024年4月26日
《大型语言模型视频理解》综述
专知会员服务
59+阅读 · 2024年1月2日
天大最新《大型语言模型评估》全面综述,111页pdf
专知会员服务
88+阅读 · 2023年10月31日
基于模型的强化学习综述
专知
42+阅读 · 2022年7月13日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
用模型不确定性理解模型
论智
11+阅读 · 2018年9月5日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
VIP会员
相关VIP内容
结合知识增强的大型语言模型复杂问题求解综述
专知会员服务
16+阅读 · 2025年5月7日
重新思考不确定性:大语言模型时代的关键综述与分析
专知会员服务
39+阅读 · 2024年11月20日
《大语言模型的数据合成与增强综述》
专知会员服务
43+阅读 · 2024年10月19日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
《大型语言模型持续学习》综述
专知会员服务
93+阅读 · 2024年4月26日
《大型语言模型视频理解》综述
专知会员服务
59+阅读 · 2024年1月2日
天大最新《大型语言模型评估》全面综述,111页pdf
专知会员服务
88+阅读 · 2023年10月31日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员