--- language: "nl" tags: - bert - sarcasm-detection - text-classification widget: - text: "We deden een man een nacht in een vat met cola en nu is hij dood" --- # Dutch Sarcasm Detector Dutch Sarcasm Detector is a text classification model built to detect sarcasm from news article titles. It is fine-tuned on bert-multilingual uncased and the training data consists of ready-made dataset available on Kaggle as well scraped data from Dutch sarcastic newspaper (De Speld). ## Training Data Datasets: - Dutch non-sarcastic data: [Kaggle: Dutch News Articles]([https://www.kaggle.com/datasets/maxscheijen/dutch-news-articles]) Scraped data: - Dutch sarcastic news from [De Speld]([https://speld.nl]) Codebase: - Git Repo: [Official repository](https://github.com/helinivan/multilingual-sarcasm-detector) --- ## Example of classification ```python 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/dutch-sarcasm-detector" tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH) model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH) text = "We deden een man een nacht in een vat met cola en nu is hij dood" tokenized_text = tokenizer([preprocess_data(text)], padding=True, truncation=True, max_length=512, 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.9999982118606567} ``` ## Performance | Model-Name | F1 | Precision | Recall | Accuracy | ------------- |:-------------| -----| -----| ----| | [helinivan/english-sarcasm-detector ](https://huggingface.co/helinivan/english-sarcasm-detector)| 94.48 | 94.46 | 94.51 | 94.48 | [helinivan/italian-sarcasm-detector ](https://huggingface.co/helinivan/italian-sarcasm-detector) | 92.99 | 92.77 | 93.24 | 93.42 | [helinivan/multilingual-sarcasm-detector ](https://huggingface.co/helinivan/multilingual-sarcasm-detector) | 90.91 | 91.51 | 90.44 | 91.55 | [helinivan/dutch-sarcasm-detector ](https://huggingface.co/helinivan/dutch-sarcasm-detector) | **89.04** | 90.16 | 88.09 | 91.43