A context-conditioned
binary sentiment classifier for Indonesian text, fine-tuned from
IndoBERT Large P2 (335M parameters). This is the binary variant of
apriandito/indobert-sentiment-classifier (3-class), designed for use cases that only need polarity detection (Negatif / Positif) without a Netral class.
Evaluated on a held-out validation set of 2,107 samples.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("apriandito/indobert-binary-sentiment-classifier")
5model = AutoModelForSequenceClassification.from_pretrained("apriandito/indobert-binary-sentiment-classifier")
6model.eval()
7
8LABELS = {0: "Negatif", 1: "Positif"}
9
10context = "harga sembako"
11text = "harga beras naik terus bikin rakyat susah"
12
13encoding = tokenizer(context, text, truncation=True, max_length=256, return_tensors="pt")
14with torch.no_grad():
15 probs = torch.softmax(model(**encoding).logits, dim=-1)[0]
16 pred = torch.argmax(probs).item()
17
18print(f"{LABELS[pred]} ({probs[pred]:.4f})")
19# Output: Negatif (0.9987)
Standard sentiment models classify text in isolation. This can lead to errors when sentiment depends on context:
All three models share the same architecture (IndoBERT Large P2, 335M params) and the same context-conditioned input format ([CLS] context [SEP] text [SEP]).
1@misc{saputra2026indobert-binary-sentiment,
2 title={IndoBERT Binary Sentiment Classifier: Context-Conditioned Binary Sentiment Classification for Indonesian Text},
3 author={Saputra, Muhammad Apriandito Arya},
4 year={2026},
5 publisher={Hugging Face},
6 url={https://huggingface.co/apriandito/indobert-binary-sentiment-classifier}
7}