get_paraphrased_sentences(model, tokenizer, sentence, num_beams=10, num_return_sequences=10)

get_paraphrased_sentences(model, tokenizer, "To paraphrase a source, you have to rewrite a passage without changing the meaning of the original text.", num_beams=10, num_return_sequences=10)

tokenizer = AutoTokenizer.from_pretrained("Vamsi/T5_Paraphrase_Paws")
model = AutoModelForSeq2SeqLM.from_pretrained("Vamsi/T5_Paraphrase_Paws")

get_paraphrased_sentences(model, tokenizer, "paraphrase: " + "One of the best ways to learn is to teach what you've already learned")

!pip install git+https://github.com/PrithivirajDamodaran/Parrot_Paraphraser.git

from parrot import Parrot

parrot = Parrot()

phrases = [
  sentence,
  "One of the best ways to learn is to teach what you've already learned",
  "Paraphrasing is the process of coming up with someone else's ideas in your own words"
]

for phrase in phrases:
  print("-"*100)
  print("Input_phrase: ", phrase)
  print("-"*100)
  paraphrases = parrot.augment(input_phrase=phrase)
  for paraphrase in paraphrases:
   print(paraphrase)

예제 #2
0
import warnings

warnings.filterwarnings("ignore")
from parrot import Parrot

parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False)
phrases = ["Can you recommed some upscale restaurants in Rome?"]
for phrase in phrases:
    print("-" * 100)
    print(phrase)
    print("-" * 100)
    para_phrases = parrot.augment(input_phrase=phrase,
                                  diversity_ranker="levenshtein",
                                  do_diverse=False,
                                  max_return_phrases=10,
                                  max_length=32,
                                  adequacy_threshold=0.99,
                                  fluency_threshold=0.90)
    for para_phrase in para_phrases:
        print(para_phrases)