haipradana commited on
Commit
2e5fc54
·
verified ·
1 Parent(s): a0d0a9a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -3
README.md CHANGED
@@ -1,3 +1,71 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - id
5
+ metrics:
6
+ - accuracy
7
+ - f1
8
+ base_model:
9
+ - indobenchmark/indobert-base-p1
10
+ tags:
11
+ - sarcasm
12
+ - satire
13
+ - bert
14
+ - indobert
15
+ ---
16
+ # Fine-tuned indoBERT pre-trained model for sarcasm and satire classification
17
+
18
+ Just check GitHub for full-code and Google Colab: https://github.com/haipradana/indobert-indonesia-sarcastic-satire-classification
19
+
20
+ ## How to use this model?
21
+
22
+
23
+ ```python
24
+ import torch
25
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
26
+
27
+ # Load model
28
+ tokenizer = AutoTokenizer.from_pretrained("indobert-indonesia-sarcastic-satire-classification/model")
29
+ model = AutoModelForSequenceClassification.from_pretrained("indobert-indonesia-sarcastic-satire-classification/model")
30
+
31
+ # Predict
32
+ def predict(text: str):
33
+ inputs = tokenizer(text, return_tensors='pt', truncation=True, padding=True, max_length=512)
34
+ with torch.no_grad():
35
+ outputs = model(**inputs)
36
+ logits = outputs.logits
37
+ prediction = torch.argmax(logits, dim=1).item()
38
+ return 'sarcasm' if prediction == 1 else 'not sarcasm'
39
+
40
+ # Example
41
+ result = predict("Kamu penulis ya? pandai sekali mengarang cerita")
42
+ print(result) #output = sarcasm
43
+ ```
44
+
45
+ ### Or just using the script in the GitHub Repos
46
+
47
+ ```bash
48
+ cd scripts
49
+ python predict.py
50
+ ```
51
+
52
+ ## Evaluation Results
53
+
54
+ The model was evaluated on the test set with the following metrics:
55
+
56
+ | Metric | Value |
57
+ |------------|---------|
58
+ | Accuracy | 0.8378 |
59
+ | Precision | 0.8405 |
60
+ | Recall | 0.8286 |
61
+ | F1-Score | 0.8345 |
62
+
63
+ ### Training History
64
+
65
+ | Epoch | Train Loss | Val Loss | Accuracy | Precision | F1-Score | Recall |
66
+ |-------|------------|----------|----------|-----------|----------|---------|
67
+ | 1 | 0.4559 | 0.3512 | 0.8409 | 0.9022 | 0.8261 | 0.7618 |
68
+ | 2 | 0.2491 | 0.3924 | 0.8339 | 0.7835 | 0.8459 | 0.9190 |
69
+ | 3 | 0.1198 | 0.5980 | 0.8429 | 0.8188 | 0.8471 | 0.8774 |
70
+ | 4 | 0.0439 | 0.9497 | 0.8444 | 0.8231 | 0.8479 | 0.8742 |
71
+ | 5 | 0.0097 | 0.9962 | 0.8522 | 0.8421 | 0.8529 | 0.8640 |