|
--- |
|
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.'}] |
|
``` |
|
|