Skip to main content
QUICK REVIEW

[Paper Review] Fault-Aware Neural Code Rankers

Jeevana Priya Inala, Chenglong Wang|arXiv (Cornell University)|Jun 4, 2022
Software Engineering ResearchComputer Science13 citations
TL;DR

This paper proposes CodeRanker, a fault-aware neural ranker that predicts program correctness without execution by classifying fine-grained error types (e.g., TypeError, IndexError). Trained on execution feedback from sampled programs, it boosts pass@1 accuracy by up to 13.6 percentage points across multiple code generation models and datasets like APPS, HumanEval, and MBPP.

ABSTRACT

Large language models (LLMs) have demonstrated an impressive ability to generate code for various programming tasks. In many instances, LLMs can generate a correct program for a task when given numerous trials. Consequently, a recent trend is to do large scale sampling of programs using a model and then filtering/ranking the programs based on the program execution on a small number of known unit tests to select one candidate solution. However, these approaches assume that the unit tests are given and assume the ability to safely execute the generated programs (which can do arbitrary dangerous operations such as file manipulations). Both of the above assumptions are impractical in real-world software development. In this paper, we propose CodeRanker, a neural ranker that can predict the correctness of a sampled program without executing it. Our CodeRanker is fault-aware i.e., it is trained to predict different kinds of execution information such as predicting the exact compile/runtime error type (e.g., an IndexError or a TypeError). We show that CodeRanker can significantly increase the pass@1 accuracy of various code generation models (including Codex, GPT-Neo, GPT-J) on APPS, HumanEval and MBPP datasets.

Motivation & Objective

  • Address the impracticality of executing LLM-generated code during inference due to security risks and dependency overhead.
  • Overcome the limitations of execution-based filtering, which requires unit tests and safe execution environments.
  • Improve pass@1 performance of code generation models by ranking sampled programs without runtime execution.
  • Develop a neural ranker that understands diverse failure modes (syntax, runtime, type errors) to better assess program correctness.
  • Enable transferability of the ranker across different code generation models and datasets without retraining.

Proposed method

  • Train a fault-aware neural ranker (CodeRanker) to predict multi-class failure modes from program execution feedback.
  • Fine-tune CodeBERT on execution outcomes (e.g., error types, output mismatches) to create a classifier for program correctness.
  • Use execution logs from sampled programs on unit tests to generate training labels, including specific error types and output types.
  • Rank candidate programs by predicted correctness probability, prioritizing those less likely to fail.
  • Leverage execution data during dataset creation, avoiding runtime execution during inference.
  • Transfer the ranker across code generation models (e.g., Codex, GPT-J, GPT-Neo) and datasets (APPS, HumanEval, MBPP) without retraining.

Experimental results

Research questions

  • RQ1Can a neural ranker trained to predict fine-grained error types improve the ranking of LLM-generated programs without execution?
  • RQ2How does fault-aware ranking compare to binary classification-based ranking in terms of pass@k and exec@k metrics?
  • RQ3To what extent can a ranker trained on one code generation model be transferred to others without retraining?
  • RQ4Does fault-aware ranking generalize to different programming tasks and datasets beyond competition-style problems?
  • RQ5Can fault-aware ranking reduce the need for expensive execution during inference while maintaining or improving accuracy?

Key findings

  • CodeRanker improves Codex’s pass@1 accuracy on the APPS validation set from 26% to 39.6% and on the test set from 3.8% to 4.5%.
  • On HumanEval, CodeRanker boosts Codex’s pass@1 from 26% to 32%, and on MBPP, from 36% to 42%.
  • The fault-aware ranker outperforms a baseline binary classifier, demonstrating the value of fine-grained error prediction.
  • The ranker is transferable: performance gains are observed on different code generation models (GPT-J, GPT-Neo) without retraining.
  • CodeRanker is more effective at detecting execution errors than intent errors, aligning with the observation that model-generated code often fails at runtime.
  • The approach reduces reliance on execution at inference time, enabling safer and more scalable code generation in real-world environments.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.