🚀 印尼語情感分析模型
本模型用於對印尼語評論和評價進行情感分析,基於預訓練的印尼語BERT模型微調而來,能將文本分為消極、中性和積極三類。
🚀 快速開始
你可以按照以下方式加載模型並進行推理:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("taufiqdp/indonesian-sentiment")
model = AutoModelForSequenceClassification.from_pretrained("taufiqdp/indonesian-sentiment")
class_names = ['negatif', 'netral', 'positif']
text = "Pelayanan lama dan tidak ramah"
tokenized_text = tokenizer(text, return_tensors='pt')
with torch.inference_mode():
logits = model(**tokenized_text)['logits']
result = class_names[logits.argmax(dim=1)]
print(result)
✨ 主要特性
📦 安裝指南
文檔未提及具體安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("taufiqdp/indonesian-sentiment")
model = AutoModelForSequenceClassification.from_pretrained("taufiqdp/indonesian-sentiment")
class_names = ['negatif', 'netral', 'positif']
text = "Pelayanan lama dan tidak ramah"
tokenized_text = tokenizer(text, return_tensors='pt')
with torch.inference_mode():
logits = model(**tokenized_text)['logits']
result = class_names[logits.argmax(dim=1)]
print(result)
📚 詳細文檔
模型詳情
本模型是 IndoBERT Base Uncased 的微調版本,這是一個在印尼語文本數據上預訓練的BERT模型。它經過微調,用於對印尼語評論和評價進行情感分析。
該模型在 indonlu (SmSA
) 和 indonesian_sentiment 數據集上進行訓練。
模型將給定的印尼語評論文本分為以下三類之一:
訓練超參數
- 訓練批次大小(train_batch_size):32
- 評估批次大小(eval_batch_size):32
- 學習率(learning_rate):1e-4
- 優化器(optimizer):AdamW,其中 betas=(0.9, 0.999),eps=1e-8,權重衰減(weight_decay)=0.01
- 訓練輪數(epochs):3
- 學習率調度器(learning_rate_scheduler):StepLR,步長(step_size)=592,衰減率(gamma)=0.1
訓練結果
以下表格展示了模型的訓練結果:
輪數 |
損失 |
準確率 |
1 |
0.2936 |
0.9310 |
2 |
0.1212 |
0.9526 |
3 |
0.0795 |
0.9569 |
🔧 技術細節
文檔中關於技術細節的描述已在“詳細文檔”部分體現,故不再單獨列出此章節。
📄 許可證
本模型使用 MIT 許可證。
📖 引用
@misc{koto2020indolem,
title={IndoLEM and IndoBERT: A Benchmark Dataset and Pre-trained Language Model for Indonesian NLP},
author={Fajri Koto and Afshin Rahimi and Jey Han Lau and Timothy Baldwin},
year={2020},
eprint={2011.00677},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@inproceedings{purwarianti2019improving,
title={Improving Bi-LSTM Performance for Indonesian Sentiment Analysis Using Paragraph Vector},
author={Ayu Purwarianti and Ida Ayu Putu Ari Crisdayanti},
booktitle={Proceedings of the 2019 International Conference of Advanced Informatics: Concepts, Theory and Applications (ICAICTA)},
pages={1--5},
year={2019},
organization={IEEE}
}