helinivan commited on
Commit
49bb491
·
1 Parent(s): 755ea93

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: "nl"
3
+ tags:
4
+ - bert
5
+ - sarcasm-detection
6
+ - text-classification
7
+ widget:
8
+ - text: "We deden een man een nacht in een vat met cola en nu is hij dood"
9
+ ---
10
+
11
+ # Dutch Sarcasm Detector
12
+
13
+ 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).
14
+
15
+
16
+ ## Training Data
17
+
18
+ Datasets:
19
+ - Dutch non-sarcastic data: [Kaggle: Dutch News Articles]([https://www.kaggle.com/datasets/maxscheijen/dutch-news-articles])
20
+
21
+ Scraped data:
22
+ - Dutch sarcastic news from [De Speld]([https://speld.nl])
23
+
24
+ Codebase:
25
+ - Git Repo: [Official repository](https://github.com/helinivan/multilingual-sarcasm-detector)
26
+
27
+ ---
28
+
29
+ ## Example of classification
30
+
31
+ ```python
32
+ from transformers import AutoModelForSequenceClassification
33
+ from transformers import AutoTokenizer
34
+ import string
35
+
36
+ def preprocess_data(text: str) -> str:
37
+ return text.lower().translate(str.maketrans("", "", string.punctuation)).strip()
38
+
39
+ MODEL_PATH = "helinivan/dutch-sarcasm-detector"
40
+
41
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
42
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
43
+
44
+ text = "We deden een man een nacht in een vat met cola en nu is hij dood"
45
+ tokenized_text = tokenizer([preprocess_data(text)], padding=True, truncation=True, max_length=512, return_tensors="pt")
46
+ output = model(**tokenized_text)
47
+ probs = output.logits.softmax(dim=-1).tolist()[0]
48
+ confidence = max(probs)
49
+ prediction = probs.index(confidence)
50
+ results = {"is_sarcastic": prediction, "confidence": confidence}
51
+
52
+ ```
53
+
54
+ Output:
55
+
56
+ ```
57
+ {'is_sarcastic': 1, 'confidence': 0.9999982118606567}
58
+ ```
59
+
60
+ ## Performance
61
+ | Model-Name | F1 | Precision | Recall | Accuracy
62
+ | ------------- |:-------------| -----| -----| ----|
63
+ | [helinivan/english-sarcasm-detector ](https://huggingface.co/helinivan/english-sarcasm-detector)| 94.48 | 94.46 | 94.51 | 94.48
64
+ | [helinivan/italian-sarcasm-detector ](https://huggingface.co/helinivan/italian-sarcasm-detector) | 92.99 | 92.77 | 93.24 | 93.42
65
+ | [helinivan/multilingual-sarcasm-detector ](https://huggingface.co/helinivan/multilingual-sarcasm-detector) | 90.91 | 91.51 | 90.44 | 91.55
66
+ | [helinivan/dutch-sarcasm-detector ](https://huggingface.co/helinivan/dutch-sarcasm-detector) | 89.04 | 90.16 | 88.09 | 91.43