llm-t97 / gpt2.py
ysn-rfd's picture
Upload 22 files
5500979 verified
raw
history blame contribute delete
296 Bytes
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)