Downloads · 30 days
6.4K
1% of all-time downloads
mdhugol/indonesia-bert-sentiment-classification
indonesia-bert-sentiment-classification is a text classification model from mdhugol. Use it when you need a label for a piece of text. It is set up for transformers.
Indonesian BERT Base Sentiment Classifier is a sentiment-text-classification model. The model was originally the pre-trained IndoBERT Base Model (phase1 - uncased) model using Prosa sentiment dataset
Downloads · 30 days
6.4K
1% of all-time downloads
All-time downloads
741K
Public
Repo size
996 MB
Likes
32
Public
Click a slice to open those files.
.bin498 MB · 100%
From the Hugging Face model README
Indonesian BERT Base Sentiment Classifier is a sentiment-text-classification model. The model was originally the pre-trained IndoBERT Base Model (phase1 - uncased) model using Prosa sentiment dataset
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForSequenceClassification
pretrained= "mdhugol/indonesia-bert-sentiment-classification"
model = AutoModelForSequenceClassification.from_pretrained(pretrained)
tokenizer = AutoTokenizer.from_pretrained(pretrained)
sentiment_analysis = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
label_index = {'LABEL_0': 'positive', 'LABEL_1': 'neutral', 'LABEL_2': 'negative'}
pos_text = "Sangat bahagia hari ini"
neg_text = "Dasar anak sialan!! Kurang ajar!!"
result = sentiment_analysis(pos_text)
status = label_index[result[0]['label']]
score = result[0]['score']
print(f'Text: {pos_text} | Label : {status} ({score * 100:.3f}%)')
result = sentiment_analysis(neg_text)
status = label_index[result[0]['label']]
score = result[0]['score']
print(f'Text: {neg_text} | Label : {status} ({score * 100:.3f}%)')