🚀 印尼语情感分析模型
本模型用于对印尼语评论和评价进行情感分析,基于预训练的印尼语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}
}