Measuring LLM Code Generation Stability via Structural Entropy

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Song, Yewei, Sun, Tiezhu, Tang, Xunzhu, Rajput, Prateek, Bissyande, Tegawende F., Klein, Jacques
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866908495486386176
author Song, Yewei
Sun, Tiezhu
Tang, Xunzhu
Rajput, Prateek
Bissyande, Tegawende F.
Klein, Jacques
author_facet Song, Yewei
Sun, Tiezhu
Tang, Xunzhu
Rajput, Prateek
Bissyande, Tegawende F.
Klein, Jacques
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2508_14288
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Measuring LLM Code Generation Stability via Structural Entropy
Song, Yewei
Sun, Tiezhu
Tang, Xunzhu
Rajput, Prateek
Bissyande, Tegawende F.
Klein, Jacques
Software Engineering
Computation and Language
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.
title Measuring LLM Code Generation Stability via Structural Entropy
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2508.14288