Whenever I try to run the following script:
from transformers import *
model = PegasusForConditionalGeneration.from_pretrained("tuner007/pegasus_paraphrase")
tokenizer = PegasusTokenizerFast.from_pretrained("tuner007/pegasus_paraphrase")
def get_paraphrased_sentences(model, tokenizer, sentence, num_return_sequences=5, num_beams=5):
inputs = tokenizer([sentence], truncation=True, padding="longest", return_tensors="pt")
outputs = model.generate(**inputs, num_beams=num_beams, num_return_sequences=num_return_sequences,)
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
sentence = "Learning is the progress of acquiring new understanding, knowledge, behaviors, skills, values, attitudes, and preferences."
get_paraphrased_sentences(model, tokenizer, sentence, num_beams=10, num_return_sequences=10)
It returns me with the following error:
2022-01-31 01:36:51.328822: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
Traceback (most recent call last):
File "text_paraphraser.py", line 4, in <module>
model = PegasusForConditionalGeneration.from_pretrained("tuner007/pegasus_paraphrase")
NameError: name 'PegasusForConditionalGeneration' is not defined
I am running this in a virtual environment inside of Anaconda if that helps, I don't have the right version of Python on my real desktop to download sentencepiece
What I have tried:
I followed the tutorial on thepythoncode.com, double-checking multiple times.