Skip to main content
QUICK REVIEW

[Paper Review] Textbooks Are All You Need

Suriya Gunasekar, Yi Zhang|arXiv (Cornell University)|Jun 20, 2023
Topic ModelingComputer Science97 citations
TL;DR

The authors train a 1.3B-parameter code model, phi-1, using a small, high-quality dataset mixture (CodeTextbook and CodeExercises) and show strong code-generation performance with significantly less data and compute than prior models, including pass@1 scores on HumanEval and MBPP.

ABSTRACT

We introduce phi-1, a new large language model for code, with significantly smaller size than competing models: phi-1 is a Transformer-based model with 1.3B parameters, trained for 4 days on 8 A100s, using a selection of ``textbook quality" data from the web (6B tokens) and synthetically generated textbooks and exercises with GPT-3.5 (1B tokens). Despite this small scale, phi-1 attains pass@1 accuracy 50.6% on HumanEval and 55.5% on MBPP. It also displays surprising emergent properties compared to phi-1-base, our model before our finetuning stage on a dataset of coding exercises, and phi-1-small, a smaller model with 350M parameters trained with the same pipeline as phi-1 that still achieves 45% on HumanEval.

Motivation & Objective

  • Investigate whether high-quality, textbook-style data can dramatically improve code-language model performance at small scale.
  • Demonstrate that a 1.3B-parameter Transformer can achieve competitive or state-of-the-art results with limited training data and compute.
  • Show emergent capabilities and nonlocal benefits arising from targeted finetuning on coding exercises.
  • Examine data curation, filtering, and potential data contamination concerns in evaluating code-models trained on synthetic datasets.

Proposed method

  • Train a decoder-only Transformer (phi-1) with 1.3B parameters (24 layers, hidden size 2048, 32 heads) on a CodeTextbook pretraining mix (filtered The Stack/StackOverflow code + synthetic textbooks) totaling ~50B tokens.
  • Finetune phi-1-base on a small CodeExercises dataset (~180M tokens) to obtain phi-1, using the same hardware and training setup with adjusted hyperparameters.
  • Compare phi-1 against larger, established models using pass@1 on HumanEval and MBPP, and analyze emergent capabilities versus phi-1-base and phi-1-small.
  • Use a combination of data filtering (GPT-4 annotation and a transformer-based classifier) to curate high-quality educational code samples, and synthesize textbooks and exercises with GPT-3.5 for pretraining and finetuning.
  • Evaluate data contamination concerns via unconventional problem sets graded by GPT-4 and data-pruning experiments to assess robustness of performance.
  • Report architecture, training settings (fp16, AdamW, linear warmup-decay, 8x A100s, Deepspeed), and dataset composition (CodeTextbook, CodeExercises).
Figure 2.1 : Pass@1 accuracy (%) on HumanEval. The grouping of bar plots correspond to the usual scaling dimensions of either increasing the compute time (more passes on the data, here from $26$ B tokens seen to $76$ B) or increasing the number of parameters of the model (here from $350$ M to $1.3$
Figure 2.1 : Pass@1 accuracy (%) on HumanEval. The grouping of bar plots correspond to the usual scaling dimensions of either increasing the compute time (more passes on the data, here from $26$ B tokens seen to $76$ B) or increasing the number of parameters of the model (here from $350$ M to $1.3$

Experimental results

Research questions

  • RQ1Can high-quality, textbook-like data reduce the need for massive training data and compute to achieve strong code-generation performance?
  • RQ2What is the impact of finetuning on small, focused datasets (CodeExercises) on code tasks beyond the finetuning set (emergent capabilities)?
  • RQ3Do data curation and synthetic data generation strategies meaningfully outperform standard code corpora in teaching programming concepts to LLMs?
  • RQ4How robust are reported results to potential data contamination or leakage from training to evaluation benchmarks?
  • RQ5What are the comparative strengths and limitations of phi-1 and larger baselines on HumanEval and MBPP?

Key findings

  • phi-1 (1.3B parameters) achieves 50.6% pass@1 on HumanEval and 55.5% on MBPP after finetuning on CodeExercises.
  • Without finetuning, phi-1-base trained on CodeTextbook reaches 29% HumanEval, and phi-1-small (350M) achieves around 45% HumanEval with the same pipeline.
  • Phi-1 outperforms many larger models on HumanEval and MBPP despite orders of magnitude less training data and compute, though GPT-4 remains an upper bound in some cases.
  • Finetuning on CodeExercises yields large performance gains and unexpected improvements in other coding tasks and library usage (e.g., external libraries like Pygame and Tkinter).
  • Data-quality-focused pretraining (CodeTextbook) plus targeted finetuning (CodeExercises) can break traditional scaling laws by achieving strong results at small scale.
  • Unconventional evaluations with GPT-4 grading and data-pruning experiments support the robustness of phi-1’s performance and mitigate concerns about data contamination.
Figure 3.1 : The number of imports among $\sim$ 880K exercises in CodeExercises (we ignore libraries imported less than 10 times). The plot code is generated by phi-1 with the prompt: “I have a dictionary, first sort the dictionary using the value, from largest to smallest. Then generate a pyplot ba
Figure 3.1 : The number of imports among $\sim$ 880K exercises in CodeExercises (we ignore libraries imported less than 10 times). The plot code is generated by phi-1 with the prompt: “I have a dictionary, first sort the dictionary using the value, from largest to smallest. Then generate a pyplot ba

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.