Dynamic Stability of LLM-Generated Code

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Rajput, Prateek, Bonkoungou, Abdoul Aziz, Song, Yewei, Kabore, Abdoul Kader, Olatunji, Iyiola E., Klein, Jacques, Bissyande, Tegewende
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866917071463383040
author Rajput, Prateek
Bonkoungou, Abdoul Aziz
Song, Yewei
Kabore, Abdoul Kader
Olatunji, Iyiola E.
Klein, Jacques
Bissyande, Tegewende
author_facet Rajput, Prateek
Bonkoungou, Abdoul Aziz
Song, Yewei
Kabore, Abdoul Kader
Olatunji, Iyiola E.
Klein, Jacques
Bissyande, Tegewende
contents Current evaluations of LLMs for code generation emphasize functional correctness, overlooking the fact that functionally correct solutions can differ significantly in algorithmic complexity. For instance, an $(O(n^2))$ versus $(O(n \log n))$ sorting algorithm may yield similar output but incur vastly different performance costs in production. This discrepancy reveals a critical limitation in current evaluation methods: they fail to capture the behavioral and performance diversity among correct solutions. To address this, we introduce a principled framework for evaluating the dynamic stability of generated code. We propose two metrics derived from opcode distributions: Static Canonical Trace Divergence (SCTD), which captures algorithmic structure diversity across generated solutions, and Dynamic Canonical Trace Divergence (DCTD), which quantifies runtime behavioral variance. Their ratio, the Behavioral Expression Factor (BEF), serves as a diagnostic signal: it indicates critical runtime instability when BEF $\ll$ 1 and functional redundancy when BEF $\gg$ 1. Empirical results on BigOBench and CodeContests show that state-of-the-art LLMs exhibit significant algorithmic variance even among functionally correct outputs. Notably, increasing sampling temperature improves pass@1 rates but degrades stability, revealing an unrecognized trade-off: searching for correct solutions in diverse output spaces introduces a "penalty of instability" between correctness and behavioral consistency. Our findings call for stability-aware objectives in code generation and new benchmarks with asymptotic test cases for robust, real-world LLM evaluation.
format Preprint
id arxiv_https___arxiv_org_abs_2511_07463
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Dynamic Stability of LLM-Generated Code
Rajput, Prateek
Bonkoungou, Abdoul Aziz
Song, Yewei
Kabore, Abdoul Kader
Olatunji, Iyiola E.
Klein, Jacques
Bissyande, Tegewende
Programming Languages
Artificial Intelligence
Software Engineering
Current evaluations of LLMs for code generation emphasize functional correctness, overlooking the fact that functionally correct solutions can differ significantly in algorithmic complexity. For instance, an $(O(n^2))$ versus $(O(n \log n))$ sorting algorithm may yield similar output but incur vastly different performance costs in production. This discrepancy reveals a critical limitation in current evaluation methods: they fail to capture the behavioral and performance diversity among correct solutions. To address this, we introduce a principled framework for evaluating the dynamic stability of generated code. We propose two metrics derived from opcode distributions: Static Canonical Trace Divergence (SCTD), which captures algorithmic structure diversity across generated solutions, and Dynamic Canonical Trace Divergence (DCTD), which quantifies runtime behavioral variance. Their ratio, the Behavioral Expression Factor (BEF), serves as a diagnostic signal: it indicates critical runtime instability when BEF $\ll$ 1 and functional redundancy when BEF $\gg$ 1. Empirical results on BigOBench and CodeContests show that state-of-the-art LLMs exhibit significant algorithmic variance even among functionally correct outputs. Notably, increasing sampling temperature improves pass@1 rates but degrades stability, revealing an unrecognized trade-off: searching for correct solutions in diverse output spaces introduces a "penalty of instability" between correctness and behavioral consistency. Our findings call for stability-aware objectives in code generation and new benchmarks with asymptotic test cases for robust, real-world LLM evaluation.
title Dynamic Stability of LLM-Generated Code
topic Programming Languages
Artificial Intelligence
Software Engineering
url https://arxiv.org/abs/2511.07463