mdhugol commited on
Commit
f8bb920
1 Parent(s): 33621ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -1
README.md CHANGED
@@ -1 +1,29 @@
1
- Indonesian BERT Base Sentiment Classifier is a sentiment-text-classification model. The model was originally the pre-trained [IndoBERT Base Model (phase1 - uncased)](https://huggingface.co/indobenchmark/indobert-base-p1) model using [Prosa sentiment dataset](https://github.com/indobenchmark/indonlu/tree/master/dataset/smsa_doc-sentiment-prosa)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Indonesian BERT Base Sentiment Classifier is a sentiment-text-classification model. The model was originally the pre-trained [IndoBERT Base Model (phase1 - uncased)](https://huggingface.co/indobenchmark/indobert-base-p1) model using [Prosa sentiment dataset](https://github.com/indobenchmark/indonlu/tree/master/dataset/smsa_doc-sentiment-prosa)
2
+
3
+ ## How to Use
4
+ ### As Text Classifier
5
+ ```python
6
+ from transformers import pipeline
7
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
8
+
9
+ pretrained_name = "mdhugol/indonesia-bert-sentiment-classification"
10
+
11
+ model = AutoModelForSequenceClassification.from_pretrained(pretrained)
12
+ tokenizer = AutoTokenizer.from_pretrained(pretrained)
13
+
14
+ sentiment_analysis = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
15
+
16
+ label_index = {'LABEL_0': 'positive', 'LABEL_1': 'neutral', 'LABEL_2': 'negative'}
17
+
18
+ pos_text = "Sangat bahagia hari ini"
19
+ neg_text = "Dasar anak sialan!! Kurang ajar!!"
20
+
21
+ result = sentiment_analysis(pos_text)
22
+ status = label_index[result[0]['label']]
23
+ score = result[0]['score']
24
+ print(f'Text: {pos_text} | Label : {status} ({score * 100:.3f}%)')
25
+
26
+ result = sentiment_analysis(neg_text)
27
+ status = label_index[result[0]['label']]
28
+ score = result[0]['score']
29
+ print(f'Text: {neg_text} | Label : {status} ({score * 100:.3f}%)')