paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Measuring LLM Code Generation Stability via Structural Entropy

通过结构熵度量大语言模型代码生成的稳定性
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 4/10 · 论文将 AST 子树结构熵用于 LLM 代码生成的稳定性评估,涉及程序分析与 LLM 的交叉,但核心目标是评价 LLM 生成质量,而非将静态分析用于 ML/Agentic 程序,也不是用 LLM 改进静态分析/形式化验证,与用户主线方向仅弱相关。引用 1 inbox
Yewei Song, Tiezhu Sun, Xunzhu Tang, Prateek Kumar Rajput, Tegawendé F. Bissyandé, Jacques Klein
crossref: 2026-09-12

AI 速览

一句话:提出基于AST子树结构熵的无参考指标,用JS散度与结构交叉熵比刻画LLM代码生成的稳定性与一致性。

评估大语言模型代码生成的稳定性对判断其可靠性至关重要,但 pass@k、BLEU、CodeBLEU 等指标依赖参考实现或执行结果。本文将结构熵概念扩展到程序领域,对固定提示下生成的每个程序抽取深度受限的 AST 子树多重集,以其相对频率构成概率分布,并用两种互补指标度量稳定性:对称有界的 Jensen–Shannon 散度衡量结构重叠,结构交叉熵比揭示缺失的高概率模式;两者均有纯结构与 token 感知变体,分别反映控制流形态与标识符层变化。该指标无参考、语言无关、不依赖执行,复杂度为 O(n,d),在标准代码生成任务上对多个主流 LLM 的基准测试表明其能揭示模型一致性与鲁棒性的细微差异。

问题
如何在不依赖参考实现、不执行程序的前提下,度量大语言模型在同一提示下代码生成结果的结构稳定性与一致性。
方法
对固定提示下多次生成的程序抽取深度受限的 AST 子树,以子树相对频率构造概率分布,再用 Jensen–Shannon 散度与结构交叉熵比(各含纯结构与 token 感知变体)度量分布差异。
评估
在标准代码生成任务上对多个主流 LLM 进行基准测试,检验 AST 驱动的结构熵能否揭示模型一致性与鲁棒性差异,并报告方法的时间复杂度为 O(n,d)。
原文摘要(Abstract)

Assessing the stability of code generation from large language models (LLMs) is essential for judging their reliability in real-world development. We extend prior "structural-entropy" concepts to the program domain by pairing entropy with abstract-syntax-tree (AST) analysis. For any fixed prompt, we collect the multiset of depth-bounded subtrees of AST in each generated program and treat their relative frequencies as a probability distribution. We then measure stability in two complementary ways: (i) Jensen–Shannon divergence, a symmetric, bounded indicator of structural overlap, and (ii) a Structural Cross-Entropy ratio that highlights missing high-probability patterns. Both metrics admit structural-only and token-aware variants, enabling separate views on control-flow shape and identifier-level variability. Unlike pass@k, BLEU, or CodeBLEU, our metrics are reference-free, language-agnostic, and execution-independent. We benchmark several leading LLMs on standard code generation tasks, demonstrating that AST-driven structural entropy reveals nuances in model consistency and robustness. The method runs in O(n,d) time with no external tests, providing a lightweight addition to the code-generation evaluation toolkit.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9247,
  title = {Measuring LLM Code Generation Stability via Structural Entropy},
  author = {Yewei Song and Tiezhu Sun and Xunzhu Tang and Prateek Kumar Rajput and Tegawendé F. Bissyandé and Jacques Klein},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00343}
}