arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2607.01903cs.AIcs.SE
收藏

重新思考LLM集成应用的复杂性度量:超越源代码

Rethinking Complexity Metrics for LLM-Integrated Applications: Beyond Source Code

Zihao Xu1, Yuekang Li1, Gelei Deng2, Yi Liu3, Zhenchang Xing45(未明确机构)

Zihao Xu, Yuekang Li, Gelei Deng, Yi Liu, Zhenchang Xing

AI总结:

提出HECATE工具,基于Prompt-as-Specification形式化方法,从提示层和代码层评估LLM集成应用的复杂性,发现提示层复杂性是独立维度,10个有效度量中7个为新增的结构广度度量。

摘要:

LLM集成应用将自然语言提示与程序代码相结合,其运行时行为大多源自提示层而非代码本身。然而,现有的复杂性度量仅在代码层面操作,完全忽略了这一行为逻辑。我们提出了HECATE,这是第一个旨在评估此类应用中提示层和代码层复杂性的工具。HECATE的核心是Prompt-as-Specification,一种受Hoare逻辑启发的形式化方法,将每个提示解释为预期行为的规范。基于已发表分类学中识别的25个复杂性维度,该工具生成了52个候选度量。我们针对从18个开源仓库收集的118个组件评估每个度量,利用版本历史派生的维护活动作为复杂性的经验代理,并丢弃任何在考虑代码规模后失去显著性的度量。只有十个度量通过了这一测试。其中七个属于我们新引入的集合;它们不是衡量总体规模,而是统计结构上不同的元素,如LLM调用点、内存属性和提示模板,我们将这种属性称为结构广度。在三个幸存的传统度量中,RFC表现出类似的广度导向特征,而Halstead N和V仅作为规模的残余效应幸存;我们的最佳度量优于所有三个。关键的是,即使将最强的代码级度量作为协变量加入,提示层度量仍然保持显著性,从而确立了提示复杂性作为一个独立维度。最后,对跨越六个保留仓库的20个组件的验证表明,两个表现最佳的度量继续预测维护工作量,支持了它们超越训练集的泛化能力。

英文摘要:

LLM-integrated applications blend natural language prompts with program code, and much of their runtime behavior originates in the prompt layer rather than in the code itself. Existing complexity metrics, however, operate solely at the code level and therefore overlook this behavioral logic entirely. We present HECATE, the first tool designed to assess complexity in both the prompt and code layers of such applications. Central to HECATE is Prompt-as-Specification, a Hoare-logic-inspired formalism that interprets every prompt as a specification of intended behavior. Grounded in 25 complexity dimensions identified across published taxonomies, the tool generates 52 candidate metrics. We assess each metric against 118 components collected from 18 open-source repositories, relying on maintenance activity derived from version history as an empirical proxy for complexity, and discard any metric that loses significance once code size is accounted for. Only ten metrics withstand this test. Seven belong to our newly introduced set; rather than measuring sheer volume, each tallies structurally distinct elements, such as LLM call sites, memory attributes, and prompt templates, an attribute we call structural breadth. Of the three surviving conventional metrics, RFC exhibits a similar breadth-oriented character, while Halstead N and V survive only as a residual effect of size; our top-performing metrics exceed all three. Crucially, the prompt-layer metrics retain significance even when the strongest code-level metric is added as a covariate, establishing prompt complexity as a dimension in its own right. A final validation on 20 components spanning six held-out repositories shows that the two best-performing metrics continue to predict maintenance effort, supporting their generalizability beyond the training set.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑