[论文解读] Evaluating Large Language Models Trained on Code
Codex 是一个基于 GPT 的模型,在公开 GitHub 代码上进行微调,展示了从文档字符串生成可运行代码的功能,在一个新的 HumanEval 基准上优于若干基线,使用多样本和单元测试时,单样本性能的最佳提升显著。
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.
研究动机与目标
- 推动开发一个以代码为中心、在公开可用代码上训练的语言模型。
- 引入一个用于代码生成的功能正确性评估框架,使用单元测试。
- 评估 Codex 在从文档字符串合成 Python 函数方面的表现,并与基线进行比较。
- 探讨采样策略和有监督微调如何影响代码生成质量。
- 讨论强大代码生成模型的局限性、风险及社会影响。
提出的方法
- 在大型 GitHub Python 语料库上对 GPT 家族模型进行微调,以创建 Codex。
- 使用包含 164 个手写题目的新型 HumanEval 数据集,通过单元测试评估功能正确性。
- 使用 pass@k 作为多样本评估中通过单元测试的代码样本的无偏估计量。
- 在若干模型尺寸上将 Codex 与 GPT-Neo、GPT-J 和 TabNine 进行比较。
- 在独立正确函数上对 Codex 进行进一步微调以创建 Codex-S 并评估收益。
- 提出一个沙箱执行环境(基于 gVisor)以安全地让生成的代码在单元测试下运行。
实验结果
研究问题
- RQ1Codex 如何在从文档字符串生成正确的 Python 函数方面,与未进行代码微调的基线相比?
- RQ2模型尺寸和采样策略对从文档字符串进行代码补全的 pass@k 性能有何影响?
- RQ3功能上正确的样本是否与如 BLEU 之类的标准代码相似性度量相关?
- RQ4对正确的独立函数进行有监督微调(Codex-S)是否能在基线 Codex 上提升性能?
- RQ5在大规模部署代码生成模型时,有哪些限制和安全考虑?
主要发现
| pass@k | k=1 | k=10 | k=100 |
|---|---|---|---|
| GPT-Neo 125M | 0.75% | 1.88% | 2.97% |
| GPT-Neo 1.3B | 4.79% | 7.47% | 16.30% |
| GPT-Neo 2.7B | 6.41% | 11.27% | 21.37% |
| GPT-J 6B | 11.62% | 15.74% | 27.74% |
| TabNine | 2.58% | 4.35% | 7.59% |
| Codex-12M | 2.00% | 3.62% | 8.58% |
| Codex-25M | 3.21% | 7.10% | 12.89% |
| Codex-42M | 5.06% | 8.80% | 15.55% |
| Codex-85M | 8.22% | 12.81% | 22.40% |
| Codex-300M | 13.17% | 20.37% | 36.27% |
| Codex-679M | 16.22% | 25.70% | 40.95% |
| Codex-2.5B | 21.36% | 35.42% | 59.50% |
| Codex-12B | 28.81% | 46.81% | 72.31% |
- 单样本下,Codex-12B 解决 28.8% 的 HumanEval 问题;GPT-3 系列接近 0%;GPT-J 解决 11.4%。
- 每个问题生成 100 个样本并通过单元测试选择最佳样本可解决 77.5% 的问题;使用均值对数概率最高的样本可得到 44.5%。
- Codex-S(在正确的独立函数上进行有监督微调)在单样本下解决 37.7%,显著超越 Codex。
- 比较中,GPT-Neo 与 GPT-J 基线落后于 Codex;Codex-12B 在 HumanEval 上达到 28.81%(pass@1),46.81%(pass@10),72.31%(pass@100);Codex-2.5B 及更大模型继续提升。
- BLEU 分数与功能正确性相关性较差,因为在功能等价的解可能 BLEU 较低,反之亦然。
- 在大多数模型尺寸下,Codex-S 通常优于 Codex;最佳采样温度随 k 而异;按均值对数概率选择样本可提升性能。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。