CoolFace
Modelpublic

codeparrot/codeparrot

sourceHugging Faceupdated 4y agoView on Hugging Face
111likes707downloads
Model Card

CodeParrot ๐Ÿฆœ

CodeParrot ๐Ÿฆœ is a GPT-2 model (1.5B parameters) trained to generate Python code. After the initial training and release of v1.0 we trained the model some more and released v1.1 (see below for details).

Usage

You can load the CodeParrot model and tokenizer directly in transformers:

Python
from transformers import AutoTokenizer, AutoModelWithLMHead
  
tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot")
model = AutoModelWithLMHead.from_pretrained("codeparrot/codeparrot")

inputs = tokenizer("def hello_world():", return_tensors="pt")
outputs = model(**inputs)

or with a pipeline:

Python
from transformers import pipeline

pipe = pipeline("text-generation", model="codeparrot/codeparrot")
outputs = pipe("def hello_world():")

Training

The model was trained on the cleaned CodeParrot ๐Ÿฆœ dataset in two steps. After the initial training (v1.0) the model was trained for another 30k steps resulting in v1.1 and you find the settings in the following table:

Configv1.0v1.1
Batch size512512
Context size10241024
Training steps50'00030'000
Gradient accumulation1616
Gradient checkpointingTrueTrue
Learning rate2e-45e-5
Weight decay0.10.1
Warmup steps750750
ScheduleCosineCosine

The training was executed on 16 x A100 (40GB) GPUs. This setting amounts to roughly 26 + 15 billion tokens.

Performance

We evaluated the model on OpenAI's HumanEval benchmark which consists of programming challenges:

Metricv1.0v1.1
pass@13.58%3.99%
pass@108.03%8.69%
pass@10014.96%17.88%

The pass@k metric tells the probability that at least one out of k generations passes the tests.

Resources