Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Competition-Level Code Generation with AlphaCode

AlphaCode generates competitive programming solutions by sampling and filtering many programs

  • Problem Language models handle simple coding tasks but fail on competitive programming problems, which need algorithmic reasoning beyond translating instructions into code. Existing test suites also miss incorrect programs, so solve rates are unreliable.
  • Method AlphaCode is an encoder-decoder transformer pre-trained on GitHub code and fine-tuned on CodeContests. It samples a very large number of programs per problem, filters them on example tests, and clusters the survivors into at most 10 submissions.
  • Results Across ten simulated Codeforces contests with over 5,000 participants, AlphaCode ranked in the top 54.3% on average. On CodeContests validation problems, the 41B model with clustering solved 34.2% under 10@1M.

Why full-program generation for competitive programming is hard

Earlier code generation work mostly handled short snippets or simple tasks with short solutions. A stripped-down AlphaCode, without the later modifications, performs similarly to Codex on such simple Python problems.

Writing a whole program from a long task description means working out how to solve the task, not only mapping the instructions to code, which is why the authors frame it as requiring deeper algorithmic reasoning. The search space is huge, the reward is sparse, and a single character edit can change behaviour even when the program does not crash.

Competitive problems are newly written for each contest and are judged on hidden tests that check edge cases and execution speed. Earlier program synthesis work on these problems reached only low single-digit solve rates.

Building CodeContests so false positives stay low

Programs that pass all available tests but are still incorrect, called false positives, are common in existing datasets, with 30% or more such programs in the authors' comparison. Lack of test coverage also lets slow but semantically correct programs count as solved, since time and memory limits are not always enforced by the tests.

To add tests, the authors mutate existing inputs with bit flips, random increments or decrements of integers, and character swaps. A mutated input is kept only if 30 correct solutions agree on its output, and generation was capped at 10 CPU hours or 200 generated tests per problem. Because of complex input formats, the full set of 200 tests was not reached for 6.3% of problems.

Problems in the validation and test splits are kept only if at least 5 hidden or generated tests produce at least 2 different outputs, which rules out constant answers such as YES or NO. With generated tests and this filtering, the estimated false positive rate of CodeContests falls from 62% to 4%, while the rate of false positives or slow solutions is still 46%.

CodeContests combines newly scraped Codeforces problems with Description2Code and CodeNet data, and the validation and test splits contain only newly scraped Codeforces problems. Metadata such as difficulty ratings and tags is available for training but is not visible during a competition, so it should not be used at test time.

Measuring solve rate with n@k and 10@k

The n@k metric counts a problem as solved if any of n evaluated samples out of k generated samples passes all hidden tests. The setting used to model competitions is 10@k, where ten submissions per problem are allowed out of k samples, and the filtering step may use only information available to competitors such as the example tests.

The pass@k metric follows Chen et al. (2021) and assumes that all k samples can be submitted, so it is an upper bound for using k samples. The reported metrics are expectations estimated by bootstrapping from a much larger sample set, which lowers the variance between runs on small validation and test sets.

Encoder-decoder model and how it is sized

Code generation is treated as sequence-to-sequence translation: the model estimates p(Y|X), where X is the natural language problem description and Y is the program.

Compared with a decoder-only model, the encoder lets tokens early in the description attend to tokens later in it, and the encoder can be sized independently of the decoder. The description encoder takes 1536 tokens while the solution decoder takes 768, and a shallow encoder with a deep decoder was found to train more efficiently without hurting solve rate.

Multi-query attention keeps a full set of query heads but shares key and value heads across the block, which reduces the memory and cache updates that dominate sampling. The lower memory cost also permits larger sampling batches, which further raises throughput. A SentencePiece tokenizer with 8,000 tokens is trained on a mix of GitHub and CodeContests data, and the encoder and decoder share it.

Pre-training on GitHub code

The pre-training corpus is a snapshot of public GitHub repositories taken on 2021/07/14, covering C++, C#, Go, Java, JavaScript, Lua, PHP, Python, Ruby, Rust, Scala and TypeScript.

The decoder learns with next-token prediction, while the encoder learns from masked language modelling, which the authors found essential for the encoder representation. Files are split at uniformly sampled pivot locations, so content before the pivot feeds the encoder and content after it feeds the decoder.

The 1B base model used a batch size of 256, and larger models were trained for more steps following the scaling guidance of Kaplan et al. (2020). The 41B model was stopped early for resource reasons, so it is less trained than the models at other scales.

Fine-tuning with tempering, value conditioning and GOLD

Fine-tuning uses the problem description as encoder input and a program solution as decoder output, again with both next-token and masked language losses.

Tempering divides the logits by a training temperature of 0.2, which sharpens the training distribution and is used to reduce overfitting. The authors reverse the direction suggested by Dabre and Fujita (2020), who used a temperature above 1, and at sampling time they divide logits by 0.12 for tempering alone or 0.25 with GOLD, tuned on validation.

CodeContests contains both correct and incorrect submissions, so value conditioning writes the correctness of a submission into the description during training, and sampling always conditions on the sample being correct. Value prediction adds an auxiliary classifier over the decoder token representations that predicts correctness during training, and it is not used during sampling.

Solving a problem is one-of-many, since many distinct programs can be correct, so the GOLD objective is used with tempering to handle the many valid solutions per problem. Metadata such as the rating and tags is prepended to the description in the same way as the rest of the text.

Large-scale sampling, filtering and clustering

At run time the system generates a very large number of samples for each problem, which the authors found to greatly improve solve rate when combined with filtering. Many design choices, such as multi-query attention and the efficiency of the architecture, were made to make this sampling affordable.

Samples are filtered on the example tests from the problem statement, which are the only tests competitors can see. The remaining samples are clustered by program behaviour, and at most 10 candidates are selected for submission.

Simulated Codeforces contests

The evaluation covers ten Codeforces contests from 2021/12/01 to 2021/12/28, each with more than 5,000 participants. The main system was an ensemble of the 41B and 9B models with clustering, which did best on validation but was slightly worse on the test contests than the 41B model alone with clustering.

For each contest the authors simulated a live run, sampled programs, filtered them on example tests, clustered them and submitted the selected candidates to Codeforces. Three runs were made to measure variance, and the estimated, best and worst rankings bound the result depending on the time penalties and accelerators assumed.

With ten submissions per problem, the average estimated percent ranking across the ten contests is 54.3%, while the best case is 48.4% and the worst case is 77.2%, where a lower percentage is better.

CodeContests solve rates and sampling scale

The metrics are 10@k, where at most 10 submissions are allowed from k samples, and pass@k, where every sample is submitted.

The 41B model with clustering solves 34.2% of validation problems under 10@1M, 31.8% under 10@100k and 21.0% under 10@1k. On the test set the same model reaches 29.6% under 10@100k, with 25.4% under 10@10k and 16.4% under 10@1k.

The 41B model consistently outperforms the 9B model, and clustering consistently improves solve rate. The gap between validation and test is attributed to different problem distributions in the two temporally separated periods, together with some overfitting.

Scaling up parameters or dataset size also improves performance, and at a fixed submission limit of 10, more samples still give large gains.

Tag conditioning and validation loss as a proxy

On validation problem 1549A, Gregor and Cryptography, prompting with the tag 'brute force' produces loop-based samples, while the tag 'number theory' produces a direct answer without a loop.

The authors compared sampling a fresh random tag set per sample, using the true problem tags, and using one random tag set per problem. Fresh random tags per sample gave the best solve rate, which the authors attribute to the extra diversity among samples, while true tags were better than a fixed random set.

During fine-tuning of an early 1B run, validation loss begins to increase after about 50k steps, which normally signals overfitting, while solve rate keeps improving. The authors hypothesise that the model shifts probability mass from atypical solutions towards typical ones, which raises solve rate while worsening loss, and they leave a full study of this relation to future work.

Limitations

The 41B model is relatively undertrained compared with the models at other scales because training was stopped early. The Codeforces evaluation covers only ten contests from one month, and the results depend on the authors' estimate of time penalties.

Even after generated tests and filtering, a significant number of CodeContests problems accept slow but semantically correct programs. Validation and test solve rates differ, so results on one split do not carry over exactly to the other.

With more than ten submissions per problem, the model continued to solve problems, but at a decreasing rate. Validation loss was not evaluated as a substitute for solve rate in a full study, so decisions such as the number of training steps still rely on the more expensive metric.

Paper info

Authors
Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d'Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, Oriol Vinyals
Venue
arXiv · Preprint
First published
2022-2-8
Added
2026-11-13
Updated
2022-2-8
Version
v1
arXiv
2203.07814
DOI
10.1126/science.abq1158
Category
cs.PL · cs.AI · cs.LG
Original paper terms
CC BY 4.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d'Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy et al. (2022). Competition-Level Code Generation with AlphaCode. arXiv:2203.07814v1. https://doi.org/10.1126/science.abq1158

BibTeX
@article{li2022competition,
  title = {{Competition-Level Code Generation with AlphaCode}},
  author = {Yujia Li and David Choi and Junyoung Chung and Nate Kushman and Julian Schrittwieser and Rémi Leblond and Tom Eccles and James Keeling and Felix Gimeno and Agustin Dal Lago and Thomas Hubert and Peter Choy and Cyprien de Masson d'Autume and Igor Babuschkin and Xinyun Chen and Po-Sen Huang and Johannes Welbl and Sven Gowal and Alexey Cherepanov and James Molloy and Daniel J. Mankowitz and Esme Sutherland Robson and Pushmeet Kohli and Nando de Freitas and Koray Kavukcuoglu and Oriol Vinyals},
  year = {2022},
  eprint = {2203.07814},
  archivePrefix = {arXiv},
  doi = {10.1126/science.abq1158},
  url = {https://arxiv.org/abs/2203.07814v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up