arXiv:2506.00750cs.SEcs.AI2025-06被引 14

首个面向真实代码的细粒度语义推理基准,助力大模型理解实际软件工程场景。

CodeSense: a Real-World Benchmark and Dataset for Code Semantic Reasoning

  • 构建真实项目代码库,通过执行追踪生成细粒度推理数据。
  • 主流LLM在细粒度任务上表现不佳,提示工程提升有限。
  • 提供可复用的追踪工具链,支持未来基准与模型优化。

理解与推理代码语义对提升代码大模型在真实软件工程任务中的能力至关重要。现有基准多基于合成数据或教学编程题,聚焦输入输出预测等粗粒度任务,难以评估模型在实际开发场景下的表现。为此,我们提出CodeSense,首个涵盖真实世界代码细粒度语义推理任务的基准。我们从真实仓库中收集了Python、C和Java项目,执行测试并获取执行轨迹,构建细粒度语义推理的真值数据集。在此基础上,对先进代码大模型进行系统评估。结果表明,模型在细粒度推理任务上存在明显性能差距;尽管链式思维和上下文学习等提示技术有所帮助,但代码语义缺失仍是核心瓶颈。除数据集、基准与评估外,本工作还开发了一套执行追踪框架与工具集,便于高效采集细粒度软件工程推理的真值数据,为后续基准建设与模型微调提供坚实基础。代码与数据详见:https://codesense-bench.github.io/。

原文摘要 · Abstract (English)

Understanding and reasoning about code semantics is essential for enhancing code LLMs' abilities to solve real-world software engineering (SE) tasks. Although several code reasoning benchmarks exist, most rely on synthetic datasets or educational coding problems and focus on coarse-grained reasoning tasks such as input/output prediction, limiting their effectiveness in evaluating LLMs in practical SE contexts. To bridge this gap, we propose CodeSense, the first benchmark that makes available a spectrum of fine-grained code reasoning tasks concerned with the software engineering of real-world code. We collected Python, C and Java software projects from real-world repositories. We executed tests from these repositories, collected their execution traces, and constructed a ground truth dataset for fine-grained semantic reasoning tasks. We then performed comprehensive evaluations on state-of-the-art LLMs. Our results show a clear performance gap for the models to handle fine-grained reasoning tasks. Although prompting techniques such as chain-of-thought and in-context learning helped, the lack of code semantics in LLMs fundamentally limits models' capabilities of code reasoning. Besides dataset, benchmark and evaluation, our work produced an execution tracing framework and tool set that make it easy to collect ground truth for fine-grained SE reasoning tasks, offering a strong basis for future benchmark construction and model post training. Our code and data are located at https://codesense-bench.github.io/.

代码推理真实数据大模型评估软件工程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。