Semesta Data Digital (SDD)
Collection
Semesta Data Digital's AI Models Pipeline • 7 items • Updated
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Model Name: sdd-emotion-general
Base Model: xlm-roberta-base
Task: Emotion classification (6-class)
Language: Indonesian
Fine-tuned XLM-RoBERTa for detecting emotions in Indonesian text.
Emotions:
| Metric | Value |
|---|---|
| Accuracy (EmoT test) | 0.7364 |
| Macro F1 | 0.7423 |
| Latency (mean) | 10.5 ms |
| Model Size | 7.5 GB |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "AzrilFahmiardi/sdd-emotion-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 detect_emotion(text: str) -> dict:
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128).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 {
"emotion": predicted_label,
"confidence": confidence
}
# Example
text = "Saya sangat senang bisa bersama keluarga hari ini!"
result = detect_emotion(text)
print(f"Emotion: {result['emotion']} ({result['confidence']:.2%})")
{
"emotion": "happy",
"confidence": 0.8934
}
| Parameter | Type | Example |
|---|---|---|
| Input | str | Indonesian text, max 128 tokens |
| Output | dict | {"emotion": "happy", "confidence": 0.89} |