Downloads · 30 days
3
5% of all-time downloads
AzrilFahmiardi/sdd-sentiment-kepolisian
sdd-sentiment-kepolisian 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-kepolisian Base Model: indobenchmark/indobert-base-p2 Task: Sentiment classification (4-class: negatif, netral, positif, irrelevant) Language: Indonesian Domain: Police-related news articles
Downloads · 30 days
3
5% of all-time downloads
All-time downloads
55
Public
Parameters
124M
498 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors498 MB · 100%
From the Hugging Face model README
Model Name: sdd-sentiment-kepolisian
Base Model: indobenchmark/indobert-base-p2
Task: Sentiment classification (4-class: negatif, netral, positif, irrelevant)
Language: Indonesian
Domain: Police-related news articles
Fine-tuned IndoBERT for sentiment analysis of Indonesian police-related news articles. Trained on full article text (title + fulltext, untruncated) rather than a short extracted excerpt — full context proved essential for distinguishing sentiment classes in this domain (see optimization report for the ablation that established this).
Classes:
| Metric | Value |
|---|---|
| Accuracy | 0.8200 |
| Macro F1 | 0.8158 |
| Weighted F1 | 0.8158 |
| Recall (negatif) | 0.8900 |
| Latency (mean) | 2.00 ms |
| Latency (p95) | 2.09 ms |
| Model Size | 474.7 MB |
Target: Macro F1 >= 0.80 and Recall (negatif) >= 0.85 — both PASS.
| Class | Precision | Recall | F1 |
|---|---|---|---|
| negatif | 0.8054 | 0.8900 | 0.8456 |
| netral | 0.7135 | 0.6100 | 0.6577 |
| positif | 0.9205 | 0.8100 | 0.8617 |
| irrelevant | 0.8362 | 0.9700 | 0.8981 |
netral is the weakest class across every experiment run for this model, and remains the main area for future improvement (see optimization report).
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "AzrilFahmiardi/sdd-sentiment-kepolisian"
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(title: str, fulltext: str) -> dict:
text = f"{title} {fulltext}"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).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
title = "Polisi Tangkap Pelaku Curanmor di Jakarta Selatan"
fulltext = "Kepolisian Resor Jakarta Selatan berhasil menangkap seorang pelaku pencurian kendaraan bermotor yang telah beraksi di beberapa lokasi..."
result = analyze_sentiment(title, fulltext)
print(f"Sentiment: {result['sentiment']} ({result['confidence']:.2%})")
{
"sentiment": "negatif",
"confidence": 0.8734
}
| Parameter | Type | Example |
|---|---|---|
| Input | str | title + fulltext berita kepolisian Indonesia (jangan dipangkas manual), max 512 tokens |
| Output | dict | {"sentiment": "negatif", "confidence": 0.87} |
This model expects title + full article text, untruncated, as input. Do not manually extract or truncate the article to a short excerpt before tokenizing — that preprocessing was tested and found to significantly degrade performance (Macro F1 dropped from ~0.86 to ~0.78, mainly on the netral class). The tokenizer's own 512-token truncation already handles arbitrarily long articles safely; no crash risk regardless of input length.