You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

BART Tweet Detoxification

Fine-tuned BART model for converting toxic text into neutral/polite versions while preserving semantic meaning.

Model Description

This model performs text-to-text transformation to detoxify toxic language. It takes potentially offensive or toxic text as input and generates a neutral, polite version while maintaining the original semantic content.

Key Features:

  • Converts toxic tweets to neutral language
  • Preserves semantic meaning
  • Maintains fluency and naturalness
  • Trained with prompt engineering techniques

Intended Uses

Primary Use Cases:

  • Content moderation assistance
  • Educational tools for communication
  • Text sanitization for public platforms
  • Research in NLP and text transformation

Out of Scope:

  • Should not be used as sole content moderation tool
  • Not intended for censorship purposes
  • Requires human review for production use

How to Use

from transformers import pipeline

detoxifier = pipeline(
    "text-generation",
    model="radwa-f/bart-tweet-detoxification"
)

toxic_text = "You're such an idiot for thinking that!"
result = detoxifier(toxic_text, max_length=128)

print(result[0]['generated_text'])
# Output: "I respectfully disagree with your perspective on that."

Alternative usage with AutoModel:

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("radwa-f/bart-tweet-detoxification")
model = AutoModelForSeq2SeqLM.from_pretrained("radwa-f/bart-tweet-detoxification")

toxic_text = "You're such an idiot for thinking that!"
inputs = tokenizer(toxic_text, return_tensors="pt", max_length=128, truncation=True)
outputs = model.generate(**inputs, max_length=128, num_beams=5, early_stopping=True)

detoxified = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(detoxified)

Training Details

Training Data

  • Dataset: ParaDetox
  • Description: Parallel corpus of toxic and neutral text pairs
  • Preprocessing: Text cleaning and normalization
  • Language: English

Training Procedure

  • Base Model: facebook/bart-large (or facebook/bart-base - confirm which you used)
  • Task: Sequence-to-sequence generation for text style transfer
  • Prompt Engineering: Applied controlled generation techniques
  • Framework: PyTorch + Hugging Face Transformers

Hardware:

  • GPU: Google Colab A100 GPU
  • Training Time: 30 min

Hyperparameters

  • Optimizer: AdamW
  • Learning Rate: 2e-5
  • Batch Size: 16
  • Epochs: 3
  • Max Length: 128 tokens

Evaluation

The model is evaluated on:

  • Semantic Similarity: How well meaning is preserved
  • Fluency: Naturalness of generated text
  • Detoxification Rate: Reduction in toxic language
  • BLEU Score: Translation quality metric
  • ROUGE Score: Text overlap metric

Limitations

  • May occasionally alter semantic meaning significantly
  • Performance varies with highly context-dependent toxicity
  • Training data biases may affect outputs
  • Not 100% accurate - requires human oversight
  • Works best with English text similar to training distribution

Ethical Considerations

This model is a research tool and should be used responsibly:

  • Not a replacement for human moderation
  • May reflect biases from training data
  • Should be tested thoroughly before production use
  • Users should be aware of limitations
  • Consider privacy and consent when processing user-generated content

Model Creators

Radwa Fattouhi

Amine Boktaya

Citation

If you use this model, please cite:

@misc{fattouhi2025detox,
  author = {Fattouhi, Radwa and Boktaya, Amine},
  title = {BART Tweet Detoxification},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/radwa-f/BART-TweetDetox}}
}

Model Card Authors

Radwa Fattouhi

  • Final-year Software Engineering Student
  • ENSA El Jadida, Morocco
  • Contact: [email protected]

Related Work

Published research: AgriAlertX - SoftwareX (Elsevier)


Model card last updated: December 2025

Downloads last month
36
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for radwa-f/BART-TweetDetox

Finetuned
(186)
this model