NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Models

Jian Jornbowrl Wang, Xiaofei Xie, Qiang Hu, Shangqing Liu, Yi Li

TL;DR

This paper investigates whether incorporating execution trace semantics improves Code Large Language Models (Code LLMs) for tasks like code repair and generation. Surprisingly, the study finds that while these semantic representations can boost prediction confidence, they offer limited practical benefits for fine-tuning and test-time scaling, challenging previous assumptions.

What Problem Does This Paper Address?

Code LLMs have shown impressive capabilities, but they often struggle with understanding the dynamic runtime behavior of programs. This limitation hinders their ability to accurately reason about code and perform complex tasks like bug fixing. Existing approaches often focus on static code analysis, neglecting the dynamic semantics crucial for a deeper understanding. Furthermore, the way semantic information is represented and integrated into models is inconsistent, making it difficult to generalize findings. This paper aims to systematically explore how different forms of execution trace-based semantic information can enhance Code LLMs, both during training (fine-tuning) and inference.

Methods

The authors introduce a generic framework for generating and integrating various types of execution trace semantic representations into prompts for Code LLMs. This framework supports both supervised fine-tuning (SFT) and post-training inference.

For fine-tuning, they propose a repair-based approach where models learn from examples containing buggy code, execution traces, and corrected code. They explore different trace representations (e.g., NEXT, SemCoder, CodeExecutor, Concise) and parameter-efficient fine-tuning techniques like LoRA.

For inference, they investigate "test-time scaling" strategies, specifically Sequential Scaling and Parallel Scaling. These methods iteratively refine candidate solutions using feedback from execution traces and checkers, aiming to improve accuracy within a fixed computational budget.

A key component of their framework is the "Trace Adapter," which processes raw execution traces into various semantic representations. They also construct a new, high-fidelity dataset for this research.

Datasets

The study utilizes several datasets:

  • Fine-tuning Datasets:
    • A custom program repair dataset, incorporating buggy code, execution traces, and patched code.
  • Datasets from Semcoder (Ding et al., 2024) for downstream tasks.
  • Evaluation Datasets:
    • Code Synthesis: HumanEval (Chen et al., 2021a), MBPP (Liu et al., 2023b).
  • Program Repair: HumanEval-R, MBPP-R (custom-collected), CRUXEval-I (Gu et al., 2024).
  • Code Reasoning: CRUXEval-I and CRUXEval-O (Gu et al., 2024).
  • Test-Time Scaling: LiveCodeBench (Jain et al., 2024).

Key Insights and Ideas

  • Semantic Information's Limited Impact on Fine-Tuning: Surprisingly, integrating execution trace information into fine-tuning datasets did not significantly enhance the performance of Code LLMs across various tasks (repair, synthesis, reasoning). In many cases, models fine-tuned without trace information performed better.
  • Trace-Based Inference Can Help, But Not Always: While fine-tuning with traces showed limited gains, test-time scaling strategies did consistently improve performance. However, the benefit of incorporating semantic information during test-time scaling was also blurred, with only one representation (Concise) showing consistent, non-detrimental results.
  • Model Dependency: The effectiveness of both fine-tuning strategies and parameter-efficient methods (like LoRA) is highly model-dependent. Some models benefit more from certain approaches than others.
  • Prediction Confidence vs. Correctness: Semantic information might boost a model's confidence in its predictions (lower uncertainty), but this doesn't necessarily translate to increased correctness in code generation. This suggests an open problem in how to leverage semantics for actual performance gains.
  • Concise Representation Stands Out: Among the tested trace representations, "Concise" (a variant of CodeExecutor) showed some promise, performing comparably to or better than the baseline in certain scenarios, especially during test-time scaling.

Key Results

  • Fine-Tuning: For program repair, SemCoder offered minor improvements (0.3-1.4%) over models without traces. For code synthesis, models without trace information performed best in over half of the cases.
  • Test-Time Scaling: Test scaling strategies consistently improved Pass@1 scores compared to greedy decoding. However, integrating semantic information into these scaling strategies only helped in about 36 out of 56 cases. Concise was the only representation that consistently performed as well as or better than the baseline without traces in 11 out of 14 cases.
  • Parameter-Efficient Fine-Tuning (PEFT): PEFT methods significantly impact performance, but their effectiveness is model-dependent. Fine-tuning without semantic information remained the best strategy for overall performance.

Limitations and Future Work

  • Limited Programming Language Support: The current framework primarily supports Python. Extending support to languages like Java and C++ is a future direction.
  • Limited LLM Size: Experiments were conducted on LLMs around 7B parameters due to computational constraints. Testing larger models could reveal different dynamics.
  • New Semantic Representations: The authors suggest designing new semantic representations that are more aligned with how Code LLMs process and understand code, potentially incorporating higher-level abstractions.
  • Effective Integration Strategies: Future work should explore more effective strategies for integrating semantic information into model training and inference, possibly through architectural modifications or specialized pretraining objectives.
  • Understanding Uncertainty: Further research is needed to understand why semantic information boosts prediction confidence but not necessarily correctness, and how to bridge this gap.

Summary updated

BibTeX
@inproceedings{wang2025do,
  author = {Jian Jornbowrl Wang and Xiaofei Xie and Qiang Hu and Shangqing Liu and Yi Li},
  title = {{Do Code Semantics Help? A Comprehensive Study on Execution Trace-Based Information for Code Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure