Downloads · 30 days
103
25% of all-time downloads
AzrilFahmiardi/sdd-sentiment-general
sdd-sentiment-general is a machine learning model from AzrilFahmiardi. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Model Name: sdd-sentiment-general Base Model: indobenchmark/indobert-base-p2 Task: Sentiment classification (3-class: negative, neutral, positive) Language: Indonesian
Downloads · 30 days
103
25% of all-time downloads
All-time downloads
419
Public
Parameters
124M
3 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt2 GB · 57%
From the Hugging Face model README
Model Name: sdd-sentiment-general
Base Model: indobenchmark/indobert-base-p2
Task: Sentiment classification (3-class: negative, neutral, positive)
Language: Indonesian
Fine-tuned IndoBERT for sentiment analysis of Indonesian news and social media text.
Classes:
| Metric | SmSA Test | News Holdout |
|---|---|---|
| Accuracy | 0.904 | 0.804 |
| Macro F1 | 0.874 | 0.805 |
| Latency (mean) | 9.53 ms | 9.53 ms |
| Model Size | 474.7 MB | - |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "AzrilFahmiardi/sdd-sentiment-general"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
def analyze_sentiment(text: str) -> dict:
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256).to(device)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probabilities = torch.softmax(logits, dim=-1)[0].cpu()
predicted_class = logits.argmax(-1).item()
predicted_label = model.config.id2label[predicted_class]
confidence = probabilities[predicted_class].item()
return {
"sentiment": predicted_label,
"confidence": confidence
}
# Example
text = "Pemerintah berhasil menurunkan inflasi, ekonomi tumbuh positif tahun ini."
result = analyze_sentiment(text)
print(f"Sentiment: {result['sentiment']} ({result['confidence']:.2%})")
{
"sentiment": "positif",
"confidence": 0.9234
}
| Parameter | Type | Example |
|---|---|---|
| Input | str | Indonesian text (news, social media), max 256 tokens |
| Output | dict | {"sentiment": "positif", "confidence": 0.92} |