imjeffhi commited on
Commit
d34e4fc
1 Parent(s): 6a35b0c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md CHANGED
@@ -1,3 +1,52 @@
1
  ---
2
  license: mit
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+ ## Introduction
5
+ A paraphrase generation model that *attempts* to give you some control over the output text using natural language. You can do this by prepending the following to the input text:
6
+
7
+
8
+ ```
9
+ Paraphrase: {distance_keyword} changes, {word_length_keyword} input.
10
+ ```
11
+
12
+ ### distance_keyword
13
+ This tells the model how much to change the input text. There are four options:
14
+ 1. small
15
+ 2. medium
16
+ 3. large
17
+ 4. gigantic
18
+
19
+ ### word_length_keyword:
20
+ Tells the model how long to make the output text relative to the input. There are three options:
21
+ 1. reduce
22
+ 2. match
23
+ 3. expand
24
+
25
+ If you only want to paraphrase and don't necessarily care about the specifics of the output, you can also prepend "Paraphrase: " alone or skip the prepending all together and just input the text you wish to paraphrase.
26
+
27
+ ## How to use:
28
+
29
+ Initializing model using GPU and Bfloat16 precision:
30
+
31
+ ```python:
32
+ from transformers import pipeline
33
+ from torch import bfloat16
34
+
35
+ para_gen = pipeline('text2text-generation', model="imjeffhi/paraphrase_generator", tokenizer="imjeffhi/paraphrase_generator", device=0, torch_dtype=bfloat16)
36
+ ```
37
+
38
+ Calling model:
39
+
40
+ ```python:
41
+ options_phrase = "Paraphrase: large changes, match input."
42
+ input_text = "A paraphrase is a restatement of the meaning of a text or passage using other words."
43
+ output = para_gen(f"{options_phrase} {input_text}", do_sample=True, top_k=10, num_return_sequences=5)
44
+ ```
45
+ Output:
46
+ ```python:
47
+ [{'generated_text': 'A paraphrase is a modification of the meaning or expression of a text or passage by using other words.'},
48
+ {'generated_text': 'A paraphrase is a continuation of the meaning of a text or a passage using other words.'},
49
+ {'generated_text': 'A paraphrase is the restatement of the meaning of a text or other passage containing other words.'},
50
+ {'generated_text': 'The paraphrase is a repetition of the meanings of a text or passage using other words.'},
51
+ {'generated_text': 'A paraphrase is a continuation of a sentence or passage by using other words.'}]
52
+ ```