Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
Text Detoxification Task is a process of transforming the text with toxic style into the text with the same meaning but with neutral style
|
5 |
+
|
6 |
+
```python
|
7 |
+
import torch
|
8 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
9 |
+
|
10 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
11 |
+
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("the-hir0/pegasus-detoxify")
|
13 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("the-hir0/pegasus-detoxify").to(device)
|
14 |
+
|
15 |
+
input_ids = tokenizer(inference_request, return_tensors="pt", padding=True).input_ids.to(device)
|
16 |
+
outputs = model.generate(input_ids=input_ids)
|
17 |
+
tokenizer.batch_decode(outputs, skip_special_tokens=True,temperature=0)
|
18 |
+
```
|