From 48d2ea5ad45e975316e9f68293dbf04bc6a5b90e Mon Sep 17 00:00:00 2001 From: Prithiviraj Damodaran Date: Sat, 8 May 2021 12:35:17 +0000 Subject: [PATCH] Update README.md --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 077d3d2..ffd13cf 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,18 @@ pip install git+https://github.com/PrithivirajDamodaran/Parrot.git # Caveat: the generate part is NOT seeded, so for a same input, multiple runs will produce DIFFERENT outputs for now from parrot import Parrot +import torch import warnings warnings.filterwarnings("ignore") + +def set_seed(seed): + torch.manual_seed(seed) + if torch.cuda.is_available(): + torch.cuda.manual_seed_all(seed) + +set_seed(42) + #Init models (make sure you init ONLY once if you integrate this to your code) parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False) @@ -33,7 +42,7 @@ for phrase in phrases: print(para_phrase) ``` -
+```
 -----------------------------------------------------------------------------
 Input_phrase: Can you recommed some upscale restaurants in Rome?
 -----------------------------------------------------------------------------
@@ -55,7 +64,43 @@ Input_phrase: What are the famous places we should not miss in Russia
 "what are some of the most important places to visit in russia?"
 "what are some of the most famous places of russia?"
 "what are some places we should not miss in russia?"
-
+``` + +### How to get syntactic and phrasal diversity/variety in your paraphrases using parrot? + +You can play with the do_diverse knob (check out the next section for more knobs). +Consider this example: do_diverse = False (default) + +``` +------------------------------------------------------------------------------ +Input_phrase: The ultimate test of your knowledge is your capacity to convey it to another. +------------------------------------------------------------------------------ +'the final test of knowledge is your capacity to impart it ' +'the ultimate test of a person's knowledge is his ability to transmit it to another ' +'the ultimate test of knowledge is the ability to communicate it to another ' +'the ultimate test of knowledge is your ability to communicate it to others ' +'the test of your knowledge is your capacity to communicate it to others ' +'the ultimate test for knowledge is the capacity to show it to another ' +'the ultimate test of your knowledge is your ability to transmit to others ' +'the ultimate test of a knowledge is your capacity to communicate it to another ' +'the ultimate test of knowledge is your capacity to transmit it to another ' +'the final test of your knowledge is your ability to convey it to another ' +``` +do_diverse = True +``` +------------------------------------------------------------------------------ +Input_phrase: The ultimate test of your knowledge is your capacity to convey it to another. +------------------------------------------------------------------------------ +'one of the ultimate tests of knowledge is your ability to communicate it to another person ' +'one of the ultimate tests of knowledge is your ability to transmit it to another person ' +'one of the ultimate tests of knowledge is your ability to communicate it to another ' +'one of the greatest tests of knowledge is your ability to convey it to another ' +'one of the ultimate tests of knowledge is your ability to transmit it to another ' +'one of the ultimate tests of knowledge is your ability to convey it to another person ' +'one of the ultimate tests of knowledge is the ability to convey it to another ' +'the ultimate test of your knowledge is your ability to communicate it to another ' +'the ultimate test of your knowledge is your ability to transmit it to another ' +``` ### Knobs