Views
No views yet
cahya/distilbert-base-indonesian1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("newreyy/sentiment-analysis-distilbert-IKN")
5model = AutoModelForSequenceClassification.from_pretrained("newreyy/sentiment-analysis-distilbert-IKN")
6
7text = "IKN akan membuka banyak lapangan kerja untuk masyarakat Kalimantan."
8
9inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
10with torch.no_grad():
11 logits = model(**inputs).logits
12 probs = torch.softmax(logits, dim=1).squeeze()
13
14pred = torch.argmax(probs).item()
15label = "Positive" if pred == 1 else "Negative"
16confidence = probs[pred].item()
17
18print(f"Sentiment: {label} (Confidence: {confidence:.2%})")0 → Negative1 → Positive| Metric | Score |
|---|---|
| Accuracy | 91.78% |
| Precision | 92% |
| Recall | 91% |
| F1-Score | 91% |
precision recall f1-score support
Negative 0.91 0.90 0.91 125
Positive 0.92 0.93 0.92 202
Overall accuracy 0.9178| Parameter | Value |
|---|---|
| Pretrained Model | DistilBERT Indonesian (by Cahya Wirawan) |
| Epochs | 6 |
| Batch Size | 16 |
| Learning Rate | 2e-5 |
| Optimizer | AdamW |
| Max Length | 512 tokens |
1@misc{newreyy_ikn_sentiment_distilbert,
2 title={Indonesian IKN Sentiment DistilBERT},
3 author={Newreyy},
4 year={2024},
5 howpublished={\url{https://huggingface.co/newreyy/sentiment-analysis-distilbert-IKN}}
6}1@misc{cahya_distilbert_indonesian,
2 title={DistilBERT Base Indonesian},
3 author={Cahya Wirawan},
4 year={2021},
5 howpublished={\url{https://huggingface.co/cahya/distilbert-base-indonesian}}
6}cahya for the base model.