Downloads · 30 days
13
0% of all-time downloads
erfansadraiye/detoxify
detoxify is a text generation model from erfansadraiye. Use it when you need the model to write or continue text. It is set up for transformers.
This model is fine-tuned to detoxify text. It has been fine-tuned on ParaDetox using the pretrained model t5-small.
Downloads · 30 days
13
0% of all-time downloads
All-time downloads
4.7K
Public
Parameters
60.5M
727 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors242 MB · 100%
From the Hugging Face model README
This model is fine-tuned to detoxify text. It has been fine-tuned on ParaDetox using the pretrained model t5-small.
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.