CodeSpecBench: Benchmarking LLMs for Executable Behavioral Specification Generation
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) can generate code from natural language, but the extent to which they capture intended program behavior remains unclear. Executable behavioral specifications, defined via preconditions and postconditions, provide a concrete means to assess such understanding. However, existing work on specification generation is constrained in evaluation methodology, task settings, and specification expressiveness. We introduce CodeSpecBench, a benchmark for executable behavioral specification generation under an execution-based evaluation protocol. CodeSpecBench supports both function-level and repository-level tasks and encodes specifications as executable Python functions. Constructed from diverse real-world codebases, it enables a realistic assessment of both correctness (accepting valid behaviors) and completeness (rejecting invalid behaviors). Evaluating 15 state-of-the-art LLMs on CodeSpecBench, we observe a sharp performance degradation on repository-level tasks, where the best model attains only a 20.2% pass rate. We further find that specification generation is substantially more challenging than code generation, indicating that strong coding performance does not necessarily reflect deep understanding of intended program semantics. Our data and code are available at https://github.com/SparksofAGI/CodeSpecBench.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 28 of its 36 references that are in the map. First posted on arXiv 14 Apr 2026.
Builds on
28 of 36 references.
References · 28
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2025DeepSeek-V3.2: Pushing the Frontier of Open Large Language Modelscited by 815
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
- 2024Large Language Model-Based Agents for Software Engineering: A Surveycited by 178
- 2024SWT-Bench: Testing and Validating Real-World Bug-Fixes with Code Agentscited by 133
- 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMscited by 70
16 more
- 2024Enchanting Program Specification Synthesis by Large Language Models using Static Analysis and Program Verificationcited by 58
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 57
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 57
- 2024SpecGen: Automated Generation of Formal Program Specifications via Large Language Modelscited by 53
- 2025UTBoost: Rigorous Evaluation of Coding Agents on SWE-Benchcited by 45
- 2024EvoCodeBench: An Evolving Code Generation Benchmark with Domain-Specific Evaluationscited by 34
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 34
- 2025CLEVER: A Curated Benchmark for Formally Verified Code Generationcited by 29
- 2025EffiBench-X: A Multi-Language Benchmark for Measuring Efficiency of LLM-Generated Codecited by 27
- 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 26
- 2025Otter: Generating Tests from Issues to Validate SWE Patchescited by 25
- 2025A Study of LLMs' Preferences for Libraries and Programming Languagescited by 20
- 2024Evaluating LLM-driven User-Intent Formalization for Verification-Aware Languagescited by 16
- 2025Can LLMs Reason About Program Semantics? A Comprehensive Evaluation of LLMs on Formal Specification Inferencecited by 16
- 2024An Empirical Evaluation of Pre-trained Large Language Models for Repairing Declarative Formal Specificationscited by 5
- 2025Can LLMs Enable Verification in Mainstream Programming?cited by 3
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026Skill Drift Is Contract Violation: Proactive Maintenance for LLM Agent Skill Librariescited by 3
- 2026Rules to Tools: Executable Checks for LLM Agents in Scientific Computingcited by 0
- 2026SpecGuard: Proving a Task Is Broken Before the Agent Cheatscited by 0
- 2026SpecGuardBench: Can Coding Agents Construct Reliable Validation Harnesses from Natural Language Specifications?cited by 0
- 2026SpecGuardBench: Can Coding Agents Construct Reliable Validation Harnesses from Natural Language Specifications?12 Oct 2026
- 2026SpecGuard: Proving a Task Is Broken Before the Agent Cheats6 Oct 2026
- 2026Rules to Tools: Executable Checks for LLM Agents in Scientific Computing29 Sep 2026
- 2026Skill Drift Is Contract Violation: Proactive Maintenance for LLM Agent Skill Libraries9 May 2026