# Codex (2021)

> A GPT model fine-tuned on GitHub code, and HumanEval, the benchmark that grades generated programs by running their unit tests.

Page: https://mralbu.github.io/ai-datasets/p/codex

## Key facts

- Title: Evaluating Large Language Models Trained on Code
- Authors: Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al.
- Venue: arXiv July 2021
- Category: LLMs
- Paper: https://www.alphaxiv.org/abs/2107.03374

## Why it matters

A production version of Codex powered GitHub Copilot, the first coding assistant used by millions of programmers. HumanEval and pass@k became the standard way to measure code generation for years, and the idea of grading by execution carried over to every coding benchmark since, including SWE-bench and Terminal-Bench.

## The idea

Fine-tune GPT models of up to 12B parameters on 159 GB of Python files from 54 million public GitHub repositories. Judge the output the way programmers do: a generated function counts only if it passes hidden unit tests, not if it looks like a reference solution. To make that measurable, write 164 new problems by hand (HumanEval) and report pass@k, the chance that at least one of k samples passes.

## The result

Codex-12B solved 28.8% of HumanEval problems with one sample, where GPT-3 solved none and the 6B GPT-J 11.6%. A version further tuned on standalone functions reached 37.7%, and 77.5% when allowed 100 samples and a check against the tests. Similar-looking code was often wrong: BLEU scores barely separated correct from incorrect programs.

## The data

- [HumanEval (2021)](https://mralbu.github.io/ai-datasets/d/humaneval.md): 164 hand-written Python problems graded by unit tests.

## Builds on

- [GPT-3 (2020)](https://mralbu.github.io/ai-datasets/p/gpt-3.md)

## Led to

- [SWE-bench (2023)](https://mralbu.github.io/ai-datasets/p/swe-bench.md)

## Part of

- [Coding agents](https://mralbu.github.io/ai-datasets/t/coding-agents.md) (step 1 of 8)
