from transformers import GPT2LMHeadModel, GPT2Tokenizer model = GPT2LMHeadModel.from_pretrained("path_to_model") # Replace with the path to your model tokenizer = GPT2Tokenizer.from_pretrained("path_to_model") # Replace with the path to your tokenizer