Code and samples from the paper "Language Models are Unsupervised Multitask Learners".
For now, we have only released a smaller (117M parameter) version of GPT-2.
See more details in our blog post.
Download the model data
sh download_model.sh 117M
Install python packages:
pip3 install -r requirements.txt
WARNING: Samples are unfiltered and may contain offensive content. |
---|
To generate unconditional samples from the small model:
python3 src/generate_unconditional_samples.py | tee samples
There are various flags for controlling the samples:
python3 src/generate_unconditional_samples.py --top_k 40 --temperature 0.7 | tee samples
While we have not yet released GPT-2 itself, you can see some unconditional samples from it:
gpt2-samples.txt
(with default settings of temperature 1 and no truncation)gpt2-topk40-samples.txt
(with temperature 1 and top_k 40 truncation)
To give the model custom prompts, you can use:
python3 src/interactive_conditional_samples.py --top_k 40
To give the model custom prompts without confirmation, you can use:
python3 src/generaete_conditional_samples.py "INPUT TEXT" --top_k 40
To run gpt-2 from a docker container:
# build container and tag as gpt-2
docker build --tag gpt-2 .
# start container in the background and add volume to sync local changes
docker run --runtime=nvidia -d -v $PWD:/gpt-2 --name gpt-2 gpt-2
# open an interactive session
docker exec -it gpt-2 bash
To build gpt-2 on a docker image (default : CPU) :
# build container and tag as xift.ai:gpt-2
./setup_docker.sh
To check all the parameters:
./run_docker.sh
./run_docker.sh "INPUT TEXT" [PARAMETERS]
Parameters :
--seed (None) : a random value is generated unless specified. give a specific integer value if you want to reproduce same results in the future.
--nsamples (1) : specify the number of samples you want to print
--length (None) : number of tokens (words) to print on each sample.
--batch_size (1) : how many inputs you want to process simultaneously. doesn't seem to affect the results.
--temperature (1) : scales logits before sampling prior to softmax.
--top_k (0) : truncates the set of logits considered to those with the highest values.
Example : ./run_docker.sh "In a shocking finding, scientist discovered a herd of unicorns living in a remote, previously unexplored valley, in the Andes Mountains." --nsamples 2 --top_k 40 --temperature .80
To run the container for condicional sample generation on some input text:
# run the container with some text
./run_docker.sh "In a shocking finding, scientist discovered a herd of unicorns living in a remote, previously unexplored valley, in the Andes Mountains." --nsamples 2 --top_k 40 --temperature .80
We may release code for evaluating the models on various benchmarks.
We are still considering release of the larger models.
Coming soon!