from transformers import GPT2Tokenizer, GPT2LMHeadModel | |
# Load pre-trained model and tokenizer | |
model_name = 'gpt2' # You can use other variants like 'gpt2-medium', 'gpt2-large', 'gpt2-xl' | |
tokenizer = GPT2Tokenizer.from_pretrained(model_name) | |
model = GPT2LMHeadModel.from_pretrained(model_name) | |