🚀 English Sarcasm Detector
The English Sarcasm Detector is a text classification model designed to detect sarcasm in news article titles. It is fine - tuned on [bert - base - uncased](https://huggingface.co/bert - base - uncased) and trained with a ready - made dataset from Kaggle.
Labels
- 0 -> Not Sarcastic
- 1 -> Sarcastic
🚀 Quick Start
The English Sarcasm Detector is a powerful tool for identifying sarcasm in English news headlines. It leverages the pre - trained bert - base - uncased
model and is fine - tuned on specific datasets.
✨ Features
- Sarcasm Detection: Accurately detects sarcasm in English news article titles.
- Fine - Tuned Model: Based on the well - known
bert - base - uncased
model.
- Diverse Datasets: Trained on datasets from Kaggle and Hugging Face.
📦 Installation
No specific installation steps are provided in the original document.
💻 Usage Examples
Basic Usage
from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer
import string
def preprocess_data(text: str) -> str:
return text.lower().translate(str.maketrans("", "", string.punctuation)).strip()
MODEL_PATH = "helinivan/english-sarcasm-detector"
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
text = "CIA Realizes It's Been Using Black Highlighters All These Years."
tokenized_text = tokenizer([preprocess_data(text)], padding=True, truncation=True, max_length=256, return_tensors="pt")
output = model(**tokenized_text)
probs = output.logits.softmax(dim=-1).tolist()[0]
confidence = max(probs)
prediction = probs.index(confidence)
results = {"is_sarcastic": prediction, "confidence": confidence}
Output:
{'is_sarcastic': 1, 'confidence': 0.9337034225463867}
📚 Documentation
Source Data
Performance
Model - Name |
F1 |
Precision |
Recall |
Accuracy |
[helinivan/english - sarcasm - detector ](https://huggingface.co/helinivan/english - sarcasm - detector) |
92.38 |
92.75 |
92.38 |
92.42 |
[helinivan/italian - sarcasm - detector ](https://huggingface.co/helinivan/italian - sarcasm - detector) |
88.26 |
87.66 |
89.66 |
88.69 |
[helinivan/multilingual - sarcasm - detector ](https://huggingface.co/helinivan/multilingual - sarcasm - detector) |
87.23 |
88.65 |
86.33 |
88.30 |
[helinivan/dutch - sarcasm - detector ](https://huggingface.co/helinivan/dutch - sarcasm - detector) |
83.02 |
84.27 |
82.01 |
86.81 |