rubert base cased sentiment rusentiment

提供商blanchefort
分类sentiment-analysis
许可证Apache-2.0
下载量334.6K
星标0

简介

这是一个基于 RuBERT-base-cased 构建的俄语情感分析模型,专门针对 RuSentiment 数据集进行了微调。它能够精准识别俄语文本中的情感极性,是处理俄语社交媒体评论、用户反馈或市场调研数据的理想选择。对于国内从事跨境电商、对俄贸易或语言研究的开发者来说,该模型提供了开箱即用的情感分类能力,无需从零训练。其上手难度低,可通过 Hugging Face Transformers 库快速集成到现有流水线中,是构建俄语文本分析工具的高效基座。

核心亮点

  • 专为俄语优化,情感识别精准度高
  • 基于 RuBERT 架构,语义理解能力强
  • 适配 RuSentiment 数据集,覆盖多种语境
  • Apache-2.0 协议,商业集成无压力
  • 通过 Transformers 库即可快速部署

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("blanchefort/rubert-base-cased-sentiment-rusentiment")
tokenizer = AutoTokenizer.from_pretrained("blanchefort/rubert-base-cased-sentiment-rusentiment")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download blanchefort/rubert-base-cased-sentiment-rusentiment

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download blanchefort/rubert-base-cased-sentiment-rusentiment config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('blanchefort/rubert-base-cased-sentiment-rusentiment')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/blanchefort/rubert-base-cased-sentiment-rusentiment

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/blanchefort/rubert-base-cased-sentiment-rusentiment

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment')
tokenizer = AutoTokenizer.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment')

完整文档

来源: HuggingFace

---
language:

  • ru

tags:
  • sentiment

  • text-classification

datasets:
  • RuSentiment

---

RuBERT for Sentiment Analysis

This is a DeepPavlov/rubert-base-cased-conversational model trained on RuSentiment.

Labels

0: NEUTRAL 1: POSITIVE 2: NEGATIVE

How to use

python
import torch
from transformers import AutoModelForSequenceClassification
from transformers import BertTokenizerFast

tokenizer = BertTokenizerFast.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment')
model = AutoModelForSequenceClassification.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment', return_dict=True)

@torch.no_grad()
def predict(text):
inputs = tokenizer(text, max_length=512, padding=True, truncation=True, return_tensors='pt')
outputs = model(inputs)
predicted = torch.nn.functional.softmax(outputs.logits, dim=1)
predicted = torch.argmax(predicted, dim=1).numpy()
return predicted

Dataset used for model training

RuSentiment**

> A. Rogers A. Romanov A. Rumshisky S. Volkova M. Gronas A. Gribov RuSentiment: An Enriched Sentiment Analysis Dataset for Social Media in Russian. Proceedings of COLING 2018.