🚀 rubert_tiny2_russian_emotion_sentiment
rubert_tiny2_russian_emotion_sentiment
模型是輕量級模型 cointegrated/rubert-tiny2
的微調版本,用於對俄語消息中的五種情緒進行分類,能夠有效識別文本中的情緒傾向,為俄語情感分析提供了有力支持。
🚀 快速開始
安裝依賴
pip install transformers torch
使用示例代碼
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
MODEL_ID = "Kostya165/rubert_tiny2_russian_emotion_sentiment"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
model.eval()
texts = [
"Сегодня отличный день!",
"Меня это всё бесит и раздражает."
]
enc = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
logits = model(**enc).logits
preds = logits.argmax(dim=-1).tolist()
id2label = model.config.id2label
labels = [id2label[p] for p in preds]
print(labels)
✨ 主要特性
該模型能夠對俄語消息進行五種情緒的分類:
- 0:aggression( aggression)
- 1:anxiety( anxiety)
- 2:neutral( neutral)
- 3:positive( positive)
- 4:sarcasm( sarcasm)
📦 安裝指南
pip install transformers torch
💻 使用示例
基礎用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
MODEL_ID = "Kostya165/rubert_tiny2_russian_emotion_sentiment"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
model.eval()
texts = [
"Сегодня отличный день!",
"Меня это всё бесит и раздражает."
]
enc = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
logits = model(**enc).logits
preds = logits.argmax(dim=-1).tolist()
id2label = model.config.id2label
labels = [id2label[p] for p in preds]
print(labels)
📚 詳細文檔
驗證結果
指標 |
值 |
Accuracy |
0.8911 |
F1 macro |
0.8910 |
F1 micro |
0.8911 |
各類別準確率:
- aggression (0): 0.9120
- anxiety (1): 0.9462
- neutral (2): 0.8663
- positive (3): 0.8884
- sarcasm (4): 0.8426
訓練詳情
- 基礎模型:
cointegrated/rubert-tiny2
- 數據集:
Kostya165/ru_emotion_dvach
- 訓練輪數:2
- 批次大小:32
- 學習率:1e-5
- 混合精度:FP16
- 正則化:Dropout 0.1,weight_decay 0.01,warmup_ratio 0.1
依賴項
transformers>=4.30.0
torch>=1.10.0
datasets
evaluate
🔧 技術細節
該模型基於 cointegrated/rubert-tiny2
進行微調,使用 Kostya165/ru_emotion_dvach
數據集進行訓練。訓練過程中採用了 2 輪訓練,批次大小為 32,學習率為 1e-5,混合精度為 FP16,並使用了 Dropout 0.1、weight_decay 0.01 和 warmup_ratio 0.1 進行正則化。在驗證集上取得了較好的分類效果,各類別準確率均較高。
📄 許可證
CC-BY-SA 4.0。
引用
@article{rubert_tiny2_russian_emotion_sentiment,
title = {Russian Emotion Sentiment Classification with RuBERT-tiny2},
author = {Kostya165},
year = {2024},
howpublished = {\url{https://huggingface.co/Kostya165/rubert_tiny2_russian_emotion_sentiment}}
}