Last active
October 27, 2019 20:47
-
-
Save dgunning/7088e417125e6796010994a8c6ccc52d to your computer and use it in GitHub Desktop.
An example of finetuning a language model using the Huggingface Transformer library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p output | |
# Install Transformers | |
pip install transformers | |
# Download the wikitext raw data files | |
if [ ! -d "wikitext-2-raw" ]; | |
then | |
wget https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-2-raw-v1.zip | |
unzip wikitext-2-raw-v1.zip | |
fi | |
# Download the huggingface language model finetuning file | |
if [ ! -f "run_lm_finetuning.py" ]; | |
then | |
wget https://raw.githubusercontent.com/huggingface/transformers/master/examples/run_lm_finetuning.py | |
fi | |
# Run the finetuning | |
python run_lm_finetuning.py --output_dir=output --overwrite_output_dir \ | |
--mlm --model_type=bert --model_name_or_path=bert-base-cased --do_train --train_data_file=wikitext-2-raw/wiki.train.raw \ | |
--do_eval --eval_data_file=wikitext-2-raw/wiki.test.raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment