Success is in the Details: Evaluate and Enhance Details Sensitivity of Code LLMs through Counterfactuals

Xianzhen Luo, Qingfu Zhu, Zhiming Zhang, Mingzheng Xu, Tianhao Cheng, Yixuan Wang, Zheng Chu, Shijie Xuyang, Zhiyuan Ma, YuanTao Fan, Wanxiang ChearXiv 2025 · OpenReview

TL;DR

This paper introduces "sensitivity" as a crucial, yet overlooked, dimension for evaluating Code LLMs, beyond just difficulty and diversity. They propose the CTF-Code benchmark to measure this sensitivity and CTF-Instruct, a framework to enhance it, leading to significant performance improvements in LLMs.

What Problem Does This Paper Address?

Current benchmarks and training methods for Code Large Language Models (Code LLMs) primarily focus on making tasks harder (difficulty) or covering more domains (diversity). However, they largely ignore a critical aspect: sensitivity to details. This refers to an LLM's ability to correctly interpret and respond to subtle changes in problem descriptions, which can drastically alter the required algorithmic logic. The authors argue that this oversight leads to LLMs that might perform well on standard tasks but fail when faced with minor, yet critical, variations in requirements, a common scenario in real-world software development.

Methods

The core of the paper's methodology lies in two main contributions:

  1. CTF-Code Benchmark Construction: This benchmark is built using counterfactual perturbations. The process involves taking existing code problems, making minimal changes to their descriptions (Q), and ensuring these changes lead to significantly different solutions (S). The goal is to create pairs of problems (Q, S) and (Q', S') where Q and Q' are semantically very similar, but S and S' are substantially different. This is achieved through a rigorous process of LLM-based generation, expert review, and a formal optimization objective that balances description similarity with solution difference.
  2. CTF-Instruct Framework: To leverage the insights from CTF-Code, the authors developed CTF-Instruct. This is an incremental instruction fine-tuning framework. It starts with existing datasets (e.g., those focused on difficulty) and generates sensitivity-enhanced data. A key component is a selection mechanism that ensures the final dataset covers all three dimensions: difficulty, diversity, and sensitivity. This framework aims to improve LLMs' ability to handle nuanced requirements without sacrificing performance on other aspects.

Datasets

  • CTF-Code Benchmark: A newly introduced benchmark specifically designed to evaluate the sensitivity of Code LLMs. It consists of 186 problems constructed using counterfactual perturbations.
  • Evol-Instruct: Used as a base dataset for generating sensitivity data in the CTF-Instruct framework, particularly for its difficulty dimension.
  • Oss-Instruct: Used as a base dataset for generating sensitivity data, particularly for its diversity dimension.
  • LiveCodeBench, HumanEval, BigCodeBench: Existing benchmarks used for evaluating the performance of LLMs fine-tuned with CTF-Instruct.

Key Insights and Ideas

  • Sensitivity is a Critical, Underexplored Dimension: The paper convincingly demonstrates that current Code LLMs exhibit significant performance drops (over 10%) on problems with subtle detail changes, highlighting a major blind spot.
  • Counterfactuals are Powerful for Revealing LLM Weaknesses: By creating minimal input changes that lead to maximal output differences, counterfactuals effectively expose LLMs' limitations in understanding nuanced requirements.
  • Incremental Training with Sensitivity Data Works: The CTF-Instruct framework shows that augmenting existing datasets with sensitivity-focused data, especially through a carefully designed selection process, leads to substantial performance gains.
  • Sensitivity is Orthogonal to Difficulty and Diversity: The benefits of sensitivity training appear to be independent of difficulty and diversity, suggesting it can be layered on top of existing training paradigms for further improvement.
  • Model Scale Matters, but Sensitivity Training is Key: While larger models show slightly better sensitivity, the paper emphasizes that targeted training with sensitivity data is crucial for significant improvements.

Key Results

  • Performance Drop on CTF-Code: State-of-the-art LLMs like GPT-40 and Qwen2.5-Coder experienced performance drops exceeding 10% on the newly proposed CTF-Code benchmark compared to original problems.
  • CTF-Instruct Improvements: LLMs fine-tuned with CTF-Instruct data achieved:
  • A 2.6% improvement on CTF-Code.
  • Over 10% performance boost on LiveCodeBench.
  • Significant gains on other benchmarks like HumanEval+ (+4.2%) and BigCodeBench-Hard (+5.2%).
  • Robustness to Detail Changes: The CTF-Instruct framework demonstrated strong cross-language generalization, achieving the best performance in several programming languages on the MultiPL-E benchmark.
  • Effectiveness of Selection Strategy: The paper's selection strategy for balancing dimensions in CTF-Instruct proved effective, leading to performance improvements compared to simply merging data.

Limitations and Future Work

  • Dataset Size and Complexity: The authors acknowledge that the CTF-Code dataset is relatively modest due to resource constraints. They suggest scaling up the dataset and exploring more complex or challenging examples.
  • Multi-Round Generation and Larger LLMs: The CTF-Instruct framework was not tested on multi-round generation tasks or on larger, more advanced LLMs. This is identified as a promising direction for future work.
  • Impact on Larger Models: While the study showed a positive correlation between model scale and sensitivity, further investigation into how CTF-Instruct impacts very large models is warranted.
  • Optimal Amount of Sensitivity Data: The paper hints at an optimal range for sensitivity data, with initial drops and subsequent increases in performance. Further research could explore this trade-off more deeply.

Summary updated

Abstract

Code Sensitivity refers to the ability of Code LLMs to recognize and respond to details changes in problem descriptions. While current code benchmarks and instruction data focus on difficulty and diversity, sensitivity is overlooked. We first introduce the CTF-Code benchmark, constructed using counterfactual perturbations, minimizing input changes while maximizing output changes. The evaluation shows that many LLMs have a more than 10\% performance drop compared to the original problems. To fully utilize sensitivity, CTF-Instruct, an incremental instruction fine-tuning framework, extends on existing data and uses a selection mechanism to meet the three dimensions of difficulty, diversity, and sensitivity. Experiments show that LLMs fine-tuned with CTF-Instruct data achieve over a 2\% improvement on CTF-Code, and more than a 10\% performance boost on LiveCodeBench, validating the feasibility of enhancing LLMs' sensitivity to improve performance.
BibTeX
@misc{luo2025success,
  author = {Xianzhen Luo and Qingfu Zhu and Zhiming Zhang and Mingzheng Xu and Tianhao Cheng and Yixuan Wang and Zheng Chu and Shijie Xuyang and Zhiyuan Ma and YuanTao Fan and Wanxiang Che},
  title = {{Success is in the Details: Evaluate and Enhance Details Sensitivity of Code LLMs through Counterfactuals}},
  year = {2025},
  eprint = {2505.14597},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.14597},
}
Figure