A newer version of this model is available:
siRendy/indobert-analisis-sentimen-review-produk-p2
IndoBERT klasifikasi Sentiment ID - 2 Kelas
Model ini merupakan hasil fine-tuning dari indobenchmark/indobert-base-p2
untuk tugas klasifikasi sentimen review produk dalam Bahasa Indonesia dengan dua label (positif dan negatif). Dataset yang digunakan terdiri dari 10.600 ulasan produk di e-commerce tokopedia.
π― Tujuan
Model ini ditujukan untuk mengklasifikasikan komentar atau ulasan menjadi dua kelas sentimen: POSITIF
dan NEGATIF
.
π§ͺ Metrics
Model ini dievaluasi menggunakan metrik:
- Accuracy
- F1 Score
π§ Base Model
βοΈ Training Arguments
Berikut adalah konfigurasi training (TrainingArguments
) yang digunakan saat pelatihan:
from transformers import TrainingArguments
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
per_device_eval_batch_size=4,
weight_decay=0.05,
eval_strategy="epoch",
save_strategy="epoch",
seed=42,
load_best_model_at_end=True,
metric_for_best_model="f1",
logging_dir="./logs",
report_to="tensorboard",
logging_steps=100,
warmup_ratio=0.05,
)
π Hasil Evaluasi
Model dievaluasi selama 3 epoch menggunakan metrik Accuracy dan F1 Score. Berikut adalah performa model pada setiap epoch:
Epoch | Training Loss | Validation Loss | Accuracy | F1 Score |
---|---|---|---|---|
1 | 0.2674 | 0.1647 | 0.9415 | 0.9416 |
2 | 0.2427 | 0.2902 | 0.9263 | 0.9258 |
3 | 0.2387 | 0.2082 | 0.9443 | 0.9442 |
Model terbaik diambil dari epoch ke-3 berdasarkan nilai F1 tertinggi.
π¨βπ» Cara Inferensi
# Load model dan tokenizer
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
import torch
# Load dari Hugging Face Hub
model = AutoModelForSequenceClassification.from_pretrained("siRendy/indobert-analisis-sentimen-review-produk")
tokenizer = AutoTokenizer.from_pretrained("siRendy/indobert-analisis-sentimen-review-produk")
# Fungsi prediksi
def predict_sentiment(text):
classifier = pipeline(
"text-classification",
model=model,
tokenizer=tokenizer,
device=0 if torch.cuda.is_available() else -1
)
result = classifier(text)[0]
return {
"sentiment": str(result["label"]),
"confidence": round(result["score"], 4)
}
# Contoh penggunaan
text = "Produk ini sangat buruk dan tidak layak dibeli."
prediction = predict_sentiment(text)
print(prediction)
- Downloads last month
- 58
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support
Model tree for siRendy/indobert-analisis-sentimen-review-produk
Base model
indobenchmark/indobert-base-p2