bertweet base sentiment analysis

提供商finiteautomata
分类text-classification
许可证Apache-2.0
下载量1.5M
星标0

简介

BERTweet-base-sentiment-analysis 是一款专门针对推特(X)等社交媒体短文本优化的情感分析模型。它基于 BERTweet 预训练模型,在海量社交媒体语料上进行了微调,能够精准识别非正式语言中的情感倾向。相比于通用 BERT 模型,它能更好地处理网络俚语、Emoji 表情及特殊的标点习惯。对于需要快速分析用户反馈、监控品牌舆情或处理非结构化短文本的开发者来说,这是一个开箱即用的轻量化方案,上手难度极低,可直接集成到 Python 文本处理管线中。

核心亮点

  • 深耕社交媒体语料,精准识别网络俚语与表情
  • 专为短文本情感分类设计,推理速度快且高效
  • Apache-2.0 协议,支持商业化部署与自由修改
  • 无需复杂预处理,直接适配非正式社交文本

使用方法

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

model = AutoModel.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
tokenizer = AutoTokenizer.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")

Hugging Face 下载

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

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

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download finiteautomata/bertweet-base-sentiment-analysis

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

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

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

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('finiteautomata/bertweet-base-sentiment-analysis')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/finiteautomata/bertweet-base-sentiment-analysis

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

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/finiteautomata/bertweet-base-sentiment-analysis

模型文件托管在 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('finiteautomata/bertweet-base-sentiment-analysis')
tokenizer = AutoTokenizer.from_pretrained('finiteautomata/bertweet-base-sentiment-analysis')

完整文档

来源: HuggingFace

---
language:
- en

tags:
- sentiment-analysis

---

Sentiment Analysis in English


bertweet-sentiment-analysis

Repository: https://github.com/finiteautomata/pysentimiento/

Model trained with SemEval 2017 corpus (around ~40k tweets). Base model is BERTweet, a RoBERTa model trained on English tweets.

Uses POS, NEG, NEU labels.

License

pysentimiento is an open-source library for non-commercial use and scientific research purposes only. Please be aware that models are trained with third-party datasets and are subject to their respective licenses.

1. TASS Dataset license
2. [SEMEval 2017 Dataset license]()

Citation

If you use pysentimiento in your work, please cite this paper

code
@misc{perez2021pysentimiento,
      title={pysentimiento: A Python Toolkit for Sentiment Analysis and SocialNLP tasks},
      author={Juan Manuel Pérez and Juan Carlos Giudici and Franco Luque},
      year={2021},
      eprint={2106.09462},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
Enjoy! 🤗