You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I completed the training and saved models like the following: model.save_pretrained("/content/drive/MyDrive/gpt_sentiment/model_rugpt3-trainer", push_to_hub=False) tokenizer.save_pretrained("/content/drive/MyDrive/gpt_sentiment/model_rugpt3-trainer", push_to_hub=False)
then I am loading the model:
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
device = torch.device('cuda')
model_name_or_path = "/content/drive/MyDrive/gpt_sentiment/model_rugpt3-trainer"
tokenizer = GPT2Tokenizer.from_pretrained(model_name_or_path,local_files_only=True)
model = GPT2LMHeadModel.from_pretrained(model_name_or_path, local_files_only=True)
model = model.to(device)
text = "Александр Сергеевич Пушкин родился в "
#input_ids = tokenizer.encode(text, return_tensors="pt").cuda()
input_ids = tokenizer(text, return_tensors="pt")['input_ids'].to(device)
out = model.generate(**input_ids,
max_length=1024,
do_sample=True,
no_repeat_ngram_size=20,
pad_token_id = 50258)
generated = decode(out[0])
print(generated)
here i am getting:
TypeError Traceback (most recent call last)
<ipython-input-58-c57a5d1ecfe7> in <module>()
17 do_sample=True,
18 no_repeat_ngram_size=20,
---> 19 pad_token_id = 50258)
20 generated = decode(out[0])
21 print(generated)
TypeError: generate() argument after ** must be a mapping, not Tensor
how can i properly load it and get the prediction for my text
The text was updated successfully, but these errors were encountered:
I completed the training and saved models like the following:
model.save_pretrained("/content/drive/MyDrive/gpt_sentiment/model_rugpt3-trainer", push_to_hub=False) tokenizer.save_pretrained("/content/drive/MyDrive/gpt_sentiment/model_rugpt3-trainer", push_to_hub=False)
then I am loading the model:
here i am getting:
how can i properly load it and get the prediction for my text
The text was updated successfully, but these errors were encountered: