File size: 2,006 Bytes
1a1420a d34e4fc 26d2b0e d34e4fc 26d2b0e d34e4fc 26d2b0e d34e4fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
---
license: mit
---
## Introduction
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:
```
Paraphrase: {distance_keyword} changes, {word_length_keyword} input.
```
### distance_keyword
This tells the model how much to change the input text. There are four options:
1. small
2. medium
3. large
4. gigantic
### word_length_keyword:
Tells the model how long to make the output text relative to the input. There are three options:
1. reduce
2. match
3. expand
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.
## How to use:
Initializing model using GPU and Bfloat16 precision:
```python
from transformers import pipeline
from torch import bfloat16
para_gen = pipeline('text2text-generation', model="imjeffhi/paraphrase_generator", tokenizer="imjeffhi/paraphrase_generator", device=0, torch_dtype=bfloat16)
```
Calling model:
```python
options_phrase = "Paraphrase: large changes, match input."
input_text = "A paraphrase is a restatement of the meaning of a text or passage using other words."
output = para_gen(f"{options_phrase} {input_text}", do_sample=True, top_k=10, num_return_sequences=5)
```
Output:
```python
[{'generated_text': 'A paraphrase is a modification of the meaning or expression of a text or passage by using other words.'},
{'generated_text': 'A paraphrase is a continuation of the meaning of a text or a passage using other words.'},
{'generated_text': 'A paraphrase is the restatement of the meaning of a text or other passage containing other words.'},
{'generated_text': 'The paraphrase is a repetition of the meanings of a text or passage using other words.'},
{'generated_text': 'A paraphrase is a continuation of a sentence or passage by using other words.'}]
```
|