Update README.md
Browse files
README.md
CHANGED
@@ -50,20 +50,39 @@ Developed by: https://exnrt.com
|
|
50 |
|
51 |
## Getting Started:
|
52 |
|
|
|
|
|
53 |
```python
|
54 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
55 |
|
56 |
-
|
57 |
-
tokenizer = AutoTokenizer.from_pretrained("Ateeqq/Text-Rewriter-Paraphraser", token='
|
58 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/Text-Rewriter-Paraphraser", token='
|
59 |
-
|
60 |
-
text
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
```
|
68 |
|
69 |
**Disclaimer:**
|
|
|
50 |
|
51 |
## Getting Started:
|
52 |
|
53 |
+
T5 model expects a task related prefix: since it is a paraphrasing task, we will add a prefix "paraphraser: "
|
54 |
+
|
55 |
```python
|
56 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
57 |
|
58 |
+
device = "cuda"
|
59 |
+
tokenizer = AutoTokenizer.from_pretrained("Ateeqq/Text-Rewriter-Paraphraser", token='your_token')
|
60 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/Text-Rewriter-Paraphraser", token='your_token').to(device)
|
61 |
+
|
62 |
+
def generate_title(text):
|
63 |
+
input_ids = tokenizer(f'paraphraser: {text}', return_tensors="pt", padding="longest", truncation=True, max_length=64).input_ids.to(device)
|
64 |
+
outputs = model.generate(
|
65 |
+
input_ids,
|
66 |
+
num_beams=4,
|
67 |
+
num_beam_groups=4,
|
68 |
+
num_return_sequences=4,
|
69 |
+
repetition_penalty=10.0,
|
70 |
+
diversity_penalty=3.0,
|
71 |
+
no_repeat_ngram_size=2,
|
72 |
+
temperature=0.8,
|
73 |
+
max_length=64
|
74 |
+
)
|
75 |
+
return tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
76 |
+
|
77 |
+
text = 'By leveraging prior model training through transfer learning, fine-tuning can reduce the amount of expensive computing power and labeled data needed to obtain large models tailored to niche use cases and business needs.'
|
78 |
+
generate_title(text)
|
79 |
+
```
|
80 |
+
### Output:
|
81 |
+
```
|
82 |
+
['The fine-tuning can reduce the amount of expensive computing power and labeled data required to obtain large models adapted for niche use cases and business needs by using prior model training through transfer learning.',
|
83 |
+
'fine-tuning, by utilizing prior model training through transfer learning, can reduce the amount of expensive computing power and labeled data required to obtain large models tailored for niche use cases and business needs.',
|
84 |
+
'Fine-tunering by using prior model training through transfer learning can reduce the amount of expensive computing power and labeled data required to obtain large models adapted for niche use cases and business needs.',
|
85 |
+
'Using transfer learning to use prior model training, fine-tuning can reduce the amount of expensive computing power and labeled data required for large models that are suitable in niche usage cases or businesses.']
|
86 |
```
|
87 |
|
88 |
**Disclaimer:**
|