quiz-generator / python_gpt2.py
koshkosh's picture
Upload python_gpt2.py
f28517c verified
raw
history blame contribute delete
380 Bytes
from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Model name to download
model_name = "gpt2"
# Download the GPT-2 model and tokenizer
model = GPT2LMHeadModel.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
# Save the model and tokenizer files locally
model.save_pretrained("./gpt2_model")
tokenizer.save_pretrained("./gpt2_tokenizer")