Measuring LLM Code Generation Stability via Structural Entropy
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Builds on 13 of its 19 references that are in the map. First posted on arXiv 19 Aug 2025.
Builds on
13 of 19 references.
References · 13
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2024Semantic Entropy Probes: Robust and Cheap Hallucination Detection in LLMscited by 259
- 2019SPoC: Search-based Pseudocode to Codecited by 176
- 2023An Empirical Study of the Non-determinism of ChatGPT in Code Generationcited by 137
- 2022Out of the BLEU: how should we assess quality of the Code Generation models?cited by 65
- 2019Does BLEU Score Work for Code Migration?cited by 49
- 2024Revisiting Code Similarity Evaluation with Abstract Syntax Tree Edit Distancecited by 26
- 2024Benchmarks and Metrics for Evaluations of Code Generation: A Critical Reviewcited by 20
1 more
- 2023Applying Information Theory to Software Evolutioncited by 1
Built on by
Citing papers per year: 2026: 2.
2 papers.