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

IFEvalCode: Controlled Code Generation

Jian Yang, Wei Zhang, Shukai Liu, Linzheng Chai, Yingshui Tan, Jiaheng Liu, Ge Zhang, Wangchunshu Zhou, Guanglin Niu, Zhoujun Li, Binyuan Hui, Junyang LinarXiv 2025 · OpenReview

Abstract

Code large language models (Code LLMs) have made significant progress in code generation by translating natural language descriptions into functional code; however, real-world applications often demand stricter adherence to detailed requirements such as coding style, line count, and structural constraints, beyond mere correctness. To address this, the paper introduces forward and backward constraints generation to improve the instruction-following capabilities of Code LLMs in controlled code generation, ensuring outputs align more closely with human-defined guidelines. The authors further present IFEvalCode, a multilingual benchmark comprising 1.6K test samples across seven programming languages (Python, Java, JavaScript, TypeScript, Shell, C++, and C#), with each sample featuring both Chinese and English queries. Unlike existing benchmarks, IFEvalCode decouples evaluation into two metrics: correctness (Corr.) and instruction-following (Instr.), enabling a more nuanced assessment. Experiments on over 40 LLMs reveal that closed-source models outperform open-source ones in controllable code generation and highlight a significant gap between the models' ability to generate correct code versus code that precisely follows instructions.

Introduction: The Compliance Gap

While modern Large Language Models (LLMs) are becoming remarkably good at writing functional code, they often struggle to follow specific stylistic or structural constraints—like avoiding temporary variables or using recursion. This paper introduces IFEvalCode, a multilingual benchmark designed to measure "controlled code generation," and reveals a startling gap: even the best models are far better at writing correct code than they are at following human instructions on how to write it.

General vs. Controllable Code Generation

The Problem: Correctness is Only Half the Battle

Most existing code benchmarks, such as HumanEval or MBPP, focus almost exclusively on correctness: does the code pass the unit tests? However, in professional software development, "correctness" is only half the battle. Developers must often adhere to strict guidelines regarding code style, memory usage, specific algorithms (e.g., "must use recursion"), or library restrictions (e.g., "no external dependencies").

The authors identify a lack of objective benchmarks for controlled code generation. Current alignment evaluations often rely on "LLM-as-a-Judge," which can be subjective or inconsistent. There is a pressing need for a framework that can objectively verify whether a model followed specific, verifiable human instructions while solving a coding task.

Methodology: Objective Verification and Data Synthesis

The researchers tackle this problem from two angles: evaluation and training.

  1. Objective Verification: For every sample in their benchmark, they designed a check_instruction function. Unlike unit tests that check outputs, these functions use regular expressions and static analysis to verify if the code actually follows the rules (e.g., checking if a specific keyword is present or if the line count exceeds a limit).
  2. Data Synthesis (Forward & Backward Constraints): To train a model to be more "controllable," they developed two data generation strategies: Forward Generation, where they select a set of constraint types and force an LLM to generate a matching problem, and Backward Generation, where they ask an LLM to summarize constraints from freely generated code.
  3. ControlledCoder: They fine-tuned a Qwen2.5-Coder-32B model using this synthesized data, creating a baseline model specifically optimized for instruction following.
The IFEvalCode data collection and model training pipeline

The IFEvalCode Benchmark

IFEvalCode contains 1,620 samples across 8 programming languages (Python, Java, JavaScript, TypeScript, Shell, C++, PHP, and C#). Crucially, every prompt is available in both English and Chinese, allowing for a cross-lingual assessment of instruction following. The benchmark decouples evaluation into two metrics: correctness (Corr.) and instruction-following (Instr.), enabling a more nuanced assessment.

Key Insights and Results

Experiments on over 40 LLMs reveal several critical findings:

  • The "Compliance Gap": A model’s ability to generate correct code is often far ahead of its ability to follow instructions. For many models, the correctness score is nearly double the instruction-following score.
  • Closed-Source Dominance: Top-tier closed-source models like Claude 3.7 Sonnet and GPT-4.5 significantly outperform open-source alternatives in following complex constraints.
  • Trainable Controllability: The authors' fine-tuned ControlledCoder (32B) achieved an instruction-following score of 34.2%, significantly outperforming its base model (20.7%) and even beating the best closed-source models in this specific metric. This proves that controllability is a distinct, trainable skill.
  • Linguistic Fragility: Instruction following is highly sensitive to linguistic framing; models often fail instructions in one language (e.g., Chinese) while passing them in another (e.g., English) for the same task.

Conclusion

IFEvalCode highlights a significant gap in current Code LLMs: the ability to follow human-defined guidelines precisely. By providing an objective, multilingual benchmark and demonstrating that controllability can be improved through targeted data synthesis, this work paves the way for more reliable and professional-grade AI coding assistants.

Summary updated

BibTeX
@misc{yang2025ifevalcode,
  author = {Jian Yang and Wei Zhang and Shukai Liu and Linzheng Chai and Yingshui Tan and Jiaheng Liu and Ge Zhang and Wangchunshu Zhou and Guanglin Niu and Zhoujun Li and Binyuan Hui and Junyang Lin},
  title = {{IFEvalCode: Controlled Code Generation}},
  year = {2025},
  eprint = {2507.22462},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.22462},
}
Figure