helinivan commited on
Commit
3d6ad07
·
1 Parent(s): 03054e7

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: "en"
3
+ tags:
4
+ - bert
5
+ - sarcasm-detection
6
+ - text-classification
7
+ widget:
8
+ - text: "CIA Realizes It's Been Using Black Highlighters All These Years."
9
+ ---
10
+
11
+ # English Sarcasm Detector
12
+
13
+ English Sarcasm Detector is a text classification model built to detect sarcasm from news article titles. It is fine-tuned on bert-base-uncased and the training data consists of ready-made dataset available on Kaggle.
14
+
15
+
16
+ ## Training Data
17
+
18
+ Datasets:
19
+ - English language data: [Kaggle: News Headlines Dataset For Sarcasm Detection]([https://www.kaggle.com/datasets/rmisra/news-headlines-dataset-for-sarcasm-detection]).
20
+
21
+ Codebase:
22
+ - Git Repo: [Official repository]([https://github.com/helinivan/multilingual-sarcasm-detector]).
23
+
24
+ ---
25
+
26
+ ## Example of classification
27
+
28
+ ```python
29
+ from transformers import AutoModelForSequenceClassification
30
+ from transformers import AutoTokenizer
31
+ import string
32
+
33
+ def preprocess_data(text: str) -> str:
34
+ return text.lower().translate(str.maketrans("", "", string.punctuation)).strip()
35
+
36
+ MODEL_PATH = "helinivan/english-sarcasm-detector"
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
39
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
40
+
41
+ text = "CIA Realizes It's Been Using Black Highlighters All These Years."
42
+ tokenized_text = tokenizer([preprocess_data(text)], padding=True, truncation=True, max_length=512, return_tensors="pt")
43
+ output = model(**tokenized_text)
44
+ probs = output.logits.softmax(dim=-1).tolist()[0]
45
+ confidence = max(probs)
46
+ prediction = probs.index(confidence)
47
+ results = {"is_sarcastic": prediction, "confidence": confidence}
48
+
49
+ ```
50
+
51
+ Output:
52
+
53
+ ```
54
+ {'is_sarcastic': 1, 'confidence': 0.9999909400939941}
55
+ ```
56
+
57
+ ## Performance
58
+ | Model-Name | F1 | Precision | Recall | Accuracy
59
+ | ------------- |:-------------| -----| -----| ----|
60
+ | helinivan/english-sarcasm-detector | 94.48 | 94.46 | 94.51 | 94.48
61
+ | helinivan/multilingual-sarcasm-detector | 90.91 | 91.51 | 90.44 | 91.55