Text Detoxification
This model is fine-tuned to detoxify text. It has been fine-tuned on ParaDetox using the pretrained model t5-small.
Usage
from transformers import T5ForConditionalGeneration,AutoTokenizer
model = T5ForConditionalGeneration.from_pretrained('erfansadraiye/detoxify')
tokenizer = AutoTokenizer.from_pretrained('erfansadraiye/detoxify')
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model.to(device)
def test_model(text):
inputs = tokenizer.encode("Detoxify following sentence from bad words: " + text, return_tensors='pt', max_length=128, truncation=True, padding='max_length')
inputs = inputs.to(device)
outputs = model.generate(inputs, max_length=128, num_beams=4, temperature=0.7)
print("Output:", tokenizer.decode(outputs[0], skip_special_tokens=True))
text = "Oh for fuck sake. This crazy moron is not even getting better."
print("Original:", text)
test_model(text)
# output: Oh, this is not even getting better.
- Downloads last month
- 33
Inference Providers
NEW
This model is not currently available via any of the supported Inference Providers.