Skip to main content
QUICK REVIEW

[Paper Review] Coder Reviewer Reranking for Code Generation

Tianyi Zhang, Changyuan Yu|arXiv (Cornell University)|Nov 29, 2022
Software Engineering ResearchComputer Science7 citations
TL;DR

This paper proposes Coder-Reviewer reranking, a prompting-based method that improves code generation by jointly scoring generated programs using both a Coder model (p(y|x)) and a Reviewer model (p(x|y)), which evaluates how well the program satisfies the original instruction. The method achieves up to 17% absolute accuracy gain over standard Coder-only reranking and outperforms MBR-exec when combined with executability filtering.

ABSTRACT

Sampling diverse programs from a code language model and reranking with model likelihood is a popular method for code generation but it is prone to preferring degenerate solutions. Inspired by collaborative programming, we propose Coder-Reviewer reranking. We augment Coder language models from past work, which generate programs given language instructions, with Reviewer models, which evaluate the likelihood of the instruction given the generated programs. We perform an extensive study across six datasets with eight models from three model families. Experimental results show that Coder-Reviewer reranking leads to consistent and significant improvement (up to 17% absolute accuracy gain) over reranking with the Coder model only. When combined with executability filtering, Coder-Reviewer reranking can often outperform the minimum Bayes risk method. Coder-Reviewer reranking is easy to implement by prompting, can generalize to different programming languages, and works well with off-the-shelf hyperparameters.

Motivation & Objective

  • Address the limitation of Coder-only reranking, which favors degenerate solutions like short or repetitive code due to mode-seeking inference.
  • Improve code generation reliability by introducing a Reviewer model that evaluates instruction adherence using reverse likelihood p(x|y).
  • Develop a simple, zero-shot prompting-based method to implement the Reviewer model without additional training.
  • Demonstrate consistent performance gains across diverse datasets, models, and programming languages.
  • Show that the method generalizes well and works effectively with off-the-shelf hyperparameters and existing filtering techniques.

Proposed method

  • Use a pretrained Coder model to generate multiple candidate programs y from a natural language instruction x.
  • For each generated program y, invert the prompt order to query the same model as a Reviewer, estimating p(x|y) via autoregressive likelihood.
  • Rerank candidates using the product of the two likelihoods: p(x|y) × p(y|x), which corresponds to a weighted Maximum Mutual Information (MMI) objective.
  • Implement the Reviewer model via few-shot prompting, avoiding any fine-tuning or additional training.
  • Combine Coder-Reviewer reranking with executability filtering to further improve performance, especially on test-case-heavy benchmarks.
  • Apply a simple degenerate solution rejection step to filter out overly short or repetitive programs before reranking.

Experimental results

Research questions

  • RQ1Can a reverse likelihood model (p(x|y)) effectively reduce bias toward degenerate code in code generation?
  • RQ2Does combining p(y|x) and p(x|y) via product scoring lead to consistent performance gains across diverse models and datasets?
  • RQ3How does Coder-Reviewer reranking compare to state-of-the-art methods like MBR-exec in terms of accuracy and practicality?
  • RQ4To what extent does the method generalize across programming languages and model families without retraining?
  • RQ5How sensitive is the method to hyperparameters like the number of samples and mixing ratio α?

Key findings

  • Coder-Reviewer reranking achieves up to 17% absolute accuracy gain over Coder-only reranking across six datasets and eight models.
  • The method consistently improves performance across all evaluated model families (e.g., Codex, CodeGen, CodeT) and programming languages (Python, Java, Bash).
  • When combined with executability filtering, Coder-Reviewer reranking often outperforms the MBR-exec method, which requires complex aggregation of executed outputs.
  • The method is robust to increasing numbers of candidate programs, showing stable performance where Coder-only reranking degrades due to degenerate solutions.
  • Degenerate solution rejection improves all methods, but the benefit is most significant for Coder-only reranking, confirming that Coder-Reviewer reduces inherent bias.
  • Hyperparameter tuning of α (mixing ratio) yields minimal gains (<1%) in most cases, indicating that α = 0.5 is a robust default choice.

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.