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

ConAIR:Consistency-Augmented Iterative Interaction Framework to Enhance the Reliability of Code Generation

Jinhao Dong, Jun Sun, Wenjie Zhang, Jin Song Dong 0001, Dan HaoarXiv 2024 · DOI

Abstract

Large Language Models (LLMs) have transformed code generation, yet their reliability remains limited by the quality of self-generated verification tests. We present ConAIR (Consistency-Augmented Iterative Interaction), a framework that enhances code reliability through a "rank-correct-fix" co-evolution process. By shifting human or oracle effort from debugging complex code to verifying "suspicious" test cases, ConAIR significantly improves performance. Our evaluations show that ConAIR boosts GPT-3.5's accuracy by an average of 32.9%, allowing it to surpass state-of-the-art models like GPT-4o.

Introduction: The Reliability Gap in LLM Code Generation

While LLMs excel at generating code, ensuring the correctness of that code is a persistent challenge. Current "Self-Consistency" methods involve generating multiple code candidates and tests, then using majority voting to select the best candidate. However, this approach fails when the generated tests themselves are incorrect—a frequent occurrence, with error rates in LLM-generated tests averaging nearly 38%. When the "consistency indicators" are flawed, the selection process becomes a "blind leading the blind" scenario.

Methodology: Rank-Correct-Fix Co-evolution

ConAIR addresses this by focusing on the quality of the tests. Instead of requiring developers to manually debug complex logic, it identifies and presents the most "suspicious" tests for verification.

  1. Ranking ($Con_{c \to t}$): The system analyzes the relationship between generated code candidates and test cases. Tests that are failed by the majority of code candidates are flagged as statistically likely to be incorrect.
  2. Correcting: A human user or a high-capability "oracle" model (e.g., OpenAI o1) reviews these flagged tests. Correcting a simple input/output pair is significantly less cognitively demanding than fixing source code.
  3. Fixing and Iterating: The corrected tests are fed back to the LLM to refine the code candidates. This co-evolutionary cycle repeats, with improved tests leading to better code, which in turn helps identify more subtle errors in the remaining tests.
The ConAIR testing and grouping mechanism identifies suspicious tests by mapping them against multiple code candidates.

Experimental Results

We evaluated ConAIR using GPT-3.5-Turbo as a base model across three major benchmarks: HumanEval, HumanEval+, and MBPP (Mostly Basic Python Problems).

Performance Gains

ConAIR achieved a massive average improvement of 32.9% in Pass@1 accuracy over the base GPT-3.5 model. Notably, the framework enabled GPT-3.5 to outperform the raw performance of GPT-4o by over 12% and exceed the previous state-of-the-art post-processing technique, MPSC, by 11.1%.

Performance comparison of ConAIR against base models and state-of-the-art techniques across HumanEval, HumanEval+, and MBPP benchmarks.

Efficiency and Cost-Effectiveness

User studies involving PhD students confirmed that the "Fixing Tests" approach is faster and easier than traditional debugging or writing code from scratch. Furthermore, using a high-tier model like OpenAI o1 as an oracle within the ConAIR framework proved to be 10x more cost-effective than using o1 to generate the code directly, as the primary generation tasks were handled by the more affordable GPT-3.5.

Conclusion

ConAIR demonstrates that the reliability of LLM-generated code can be significantly enhanced by improving the quality of the evaluation metrics (tests) through targeted interaction. By leveraging the "consistency prerequisite," ConAIR turns the weakness of self-generated tests into a strength, providing a scalable and user-friendly path toward more dependable AI-assisted programming.

Summary updated

BibTeX
@misc{dong2024conair,
  author = {Jinhao Dong and Jun Sun and Wenjie Zhang and Jin Song Dong and Dan Hao},
  title = {{ConAIR:Consistency-Augmented Iterative Interaction Framework to Enhance the Reliability of Code Generation}},
  year = {2024},
  eprint = {2411.15587},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.15587},
}
Figure