YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Model Card: Sentiment General

Model Overview

Model Name: sdd-sentiment-general
Base Model: indobenchmark/indobert-base-p2
Task: Sentiment classification (3-class: negative, neutral, positive)
Language: Indonesian


Model Description

Fine-tuned IndoBERT for sentiment analysis of Indonesian news and social media text.

Classes:

  • negatif (Negative)
  • netral (Neutral)
  • positif (Positive)

Performance Metrics

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 -

Usage

Load Model

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)

Inference

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%})")

Output Format

{
  "sentiment": "positif",
  "confidence": 0.9234
}

Input/Output

Parameter Type Example
Input str Indonesian text (news, social media), max 256 tokens
Output dict {"sentiment": "positif", "confidence": 0.92}
Downloads last month
146
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including AzrilFahmiardi/sdd-sentiment-general