import transformers from transformers import GPT2LMHeadModel, GPT2Tokenizer import torch model_name_or_path = 'pages/models/gpt' tokenizer = GPT2Tokenizer.from_pretrained('sberbank-ai/rugpt3small_based_on_gpt2') model = GPT2LMHeadModel.from_pretrained(model_name_or_path).to('cpu')