Skip to main content
QUICK REVIEW

[Paper Review] Evaluating Large Language Models Trained on Code

Mark Chen, Jerry Tworek|arXiv (Cornell University)|Jul 7, 2021
Software Engineering ResearchComputer Science96 references1,403 citations
TL;DR

Codex is a GPT-based model fine-tuned on public GitHub code that demonstrates functional code generation from docstrings, outperforming several baselines on a new HumanEval benchmark, with best single-sample performance improving markedly when using multiple samples and unit tests.

ABSTRACT

We introduce Codex, a GPT language model fine-tuned on publicly available code from GitHub, and study its Python code-writing capabilities. A distinct production version of Codex powers GitHub Copilot. On HumanEval, a new evaluation set we release to measure functional correctness for synthesizing programs from docstrings, our model solves 28.8% of the problems, while GPT-3 solves 0% and GPT-J solves 11.4%. Furthermore, we find that repeated sampling from the model is a surprisingly effective strategy for producing working solutions to difficult prompts. Using this method, we solve 70.2% of our problems with 100 samples per problem. Careful investigation of our model reveals its limitations, including difficulty with docstrings describing long chains of operations and with binding operations to variables. Finally, we discuss the potential broader impacts of deploying powerful code generation technologies, covering safety, security, and economics.

Motivation & Objective

  • Motivate the development of a code-focused language model trained on publicly available code.
  • Introduce a functional correctness evaluation framework for code generation using unit tests.
  • Assess Codex performance on Python function synthesis from docstrings and compare to baselines.
  • Explore how sampling strategy and supervised fine-tuning affect code generation quality.
  • Discuss limitations, risks, and societal impacts of powerful code generation models.

Proposed method

  • Fine-tune GPT-family models on a large GitHub Python corpus to create Codex.
  • Evaluate functional correctness with a new HumanEval dataset of 164 hand-written problems using unit tests.
  • Use pass@k as an unbiased estimator for multi-sample evaluation of code samples passing unit tests.
  • Compare Codex against GPT-Neo, GPT-J, and TabNine across several model sizes.
  • Fine-tune Codex further on standalone correct functions to create Codex-S and assess gains.
  • Propose a sandboxed execution environment (gVisor-based) to safely run generated code against unit tests.

Experimental results

Research questions

  • RQ1How well can Codex generate correct Python functions from docstrings compared to non-code-fine-tuned baselines?
  • RQ2What is the impact of model size and sampling strategy on pass@k performance for code completion from docstrings?
  • RQ3Do functionally correct samples correlate with standard code similarity metrics like BLEU?
  • RQ4Can supervised fine-tuning on correct standalone functions (Codex-S) improve performance over base Codex?
  • RQ5What are the limitations and safety considerations of deploying code-generating LLMs at scale?

Key findings

  • With a single sample, Codex-12B solves 28.8% of HumanEval problems; GPT-3 family solves near 0%; GPT-J solves 11.4%.
  • Generating 100 samples per problem and selecting the best (by unit tests) solves 77.5% of problems; using the sample with highest mean log-probability yields 44.5%.
  • Codex-S (supervised fine-tuned on correct standalone functions) solves 37.7% with a single sample, outperforming Codex by notable margins.
  • In comparisons, GPT-Neo and GPT-J baselines lag Codex; Codex-12B reaches 28.81% (pass@1), 46.81% (pass@10), 72.31% (pass@100) on HumanEval; Codex-2.5B and larger continue to improve.
  • BLEU scores poorly correlate with functional correctness, as functionally equivalent solutions may have low BLEU and vice versa.
  • Codex-S generally outperforms Codex across model sizes; optimal sampling temperatures differ by k; selecting samples by mean log probability improves performance.

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.