haipradana commited on
Commit
c5524b2
·
verified ·
1 Parent(s): 908dd41

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -3
README.md CHANGED
@@ -4,6 +4,55 @@ datasets:
4
  - haipradana/indonesian-twitter-hate-speech-cleaned
5
  language:
6
  - id
7
- base_model:
8
- - cardiffnlp/twitter-roberta-base-sentiment-latest
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - haipradana/indonesian-twitter-hate-speech-cleaned
5
  language:
6
  - id
7
+ tags:
8
+ - bert
9
+ - RoBERTa
10
+ - tweet
11
+ - hate
12
+ - twitter
13
+ ---
14
+
15
+ # Fine-tuned RoBERTa pre-trained model to classify Indonesian hate tweet(s)
16
+
17
+ Just check GitHub for full-code and Google Colab: https://github.com/haipradana/RoBERTa-Indonesian-Hate-Tweet-Classification/tree/main
18
+
19
+ This project fine-tunes a RoBERTa model from [cardiffnlp/twitter-roberta-base-sentiment-latest](https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest) to classify Indonesian tweets as either **neutral** or **hate speech**.
20
+
21
+ ## How to use this model?
22
+
23
+
24
+ ```python
25
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
26
+ import torch
27
+
28
+ # Load model
29
+ tokenizer = AutoTokenizer.from_pretrained('./model')
30
+ model = AutoModelForSequenceClassification.from_pretrained('./model')
31
+
32
+ # Predict
33
+ def predict(text):
34
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=511)
35
+ with torch.no_grad():
36
+ outputs = model(**inputs)
37
+ prediction = torch.argmax(outputs.logits, dim=1).item()
38
+ return 'hate' if prediction == 1 else 'neutral'
39
+
40
+ # Example
41
+ result = predict("Paru-parumu terbuat dari batu ya? udah sakit gini masih aja merokok!")
42
+ print(result) # Output: hate
43
+ ```
44
+
45
+ ### Or just using the script in the GitHub Repos
46
+
47
+ ```bash
48
+ cd scripts
49
+ python predict.py
50
+ ```
51
+ ## Performance Metrics
52
+
53
+ ```
54
+ Accuracy: 82.01%
55
+ Precision: 82.68%
56
+ Recall: 81.72%
57
+ F1-Score: 82.19%
58
+ ```