Roberta Base Finetuned Chinanews Chinese
模型简介
该模型是基于RoBERTa架构的中文文本分类模型,经过中国新闻数据集微调,能够准确识别新闻文本的主题类别。
模型特点
高质量微调
基于RoBERTa-Base预训练模型,在中国新闻数据集上进行了精细微调
多类别分类
能够识别中国新闻中的多种主题类别
长文本处理
支持最长512个token的文本序列输入
模型能力
中文文本分类
新闻主题识别
情感分析(仅限特定模型)
使用案例
新闻媒体
新闻自动分类
自动将新闻文章分类到预定义的类别中
在测试集上达到高准确率
内容分析
舆情监测
分析新闻报道的主题分布和趋势
🚀 中文RoBERTa-Base文本分类模型
本项目提供了5个经过微调的中文RoBERTa-Base文本分类模型,可有效解决文本分类任务,为中文文本处理提供了强大的支持。
🚀 快速开始
你可以使用以下代码直接调用该模型进行文本分类(以 roberta-base-finetuned-chinanews-chinese
为例):
>>> from transformers import AutoModelForSequenceClassification,AutoTokenizer,pipeline
>>> model = AutoModelForSequenceClassification.from_pretrained('uer/roberta-base-finetuned-chinanews-chinese')
>>> tokenizer = AutoTokenizer.from_pretrained('uer/roberta-base-finetuned-chinanews-chinese')
>>> text_classification = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
>>> text_classification("北京上个月召开了两会")
[{'label': 'mainland China politics', 'score': 0.7211663722991943}]
✨ 主要特性
- 本套模型由 UER-py 微调得到,相关介绍见 此论文。
- 模型也可由 TencentPretrain 微调,该框架继承自 UER-py,支持参数超十亿的模型,并扩展为多模态预训练框架,相关介绍见 此论文。
📦 安装指南
文档中未提及安装相关内容,可参考 transformers
库的安装方式进行安装。
💻 使用示例
基础用法
使用 roberta-base-finetuned-chinanews-chinese
模型进行文本分类:
>>> from transformers import AutoModelForSequenceClassification,AutoTokenizer,pipeline
>>> model = AutoModelForSequenceClassification.from_pretrained('uer/roberta-base-finetuned-chinanews-chinese')
>>> tokenizer = AutoTokenizer.from_pretrained('uer/roberta-base-finetuned-chinanews-chinese')
>>> text_classification = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
>>> text_classification("北京上个月召开了两会")
[{'label': 'mainland China politics', 'score': 0.7211663722991943}]
📚 详细文档
模型下载
你可以从 UER-py 模型库页面 下载这5个中文 RoBERTa-Base 分类模型,也可以通过 HuggingFace 从以下链接下载:
数据集 | 链接 |
---|---|
JD full | roberta-base-finetuned-jd-full-chinese |
JD binary | roberta-base-finetuned-jd-binary-chinese |
Dianping | roberta-base-finetuned-dianping-chinese |
Ifeng | roberta-base-finetuned-ifeng-chinese |
Chinanews | roberta-base-finetuned-chinanews-chinese |
训练数据
使用了5个中文文本分类数据集。其中,JD full、JD binary 和 Dianping 数据集包含不同情感极性的用户评论;Ifeng 和 Chinanews 数据集包含不同主题类别的新闻文章首段。这些数据集由 Glyph 项目收集,更多详细信息见 相应论文。
训练过程
模型在 腾讯云 上使用 UER-py 进行微调。在预训练模型 chinese_roberta_L-12_H-768 的基础上,以序列长度512进行3个轮次的微调。在每个轮次结束时,当模型在开发集上达到最佳性能时进行保存。不同模型使用相同的超参数。
以 roberta-base-finetuned-chinanews-chinese
为例:
python3 finetune/run_classifier.py --pretrained_model_path models/cluecorpussmall_roberta_base_seq512_model.bin-250000 \
--vocab_path models/google_zh_vocab.txt \
--train_path datasets/glyph/chinanews/train.tsv \
--dev_path datasets/glyph/chinanews/dev.tsv \
--output_model_path models/chinanews_classifier_model.bin \
--learning_rate 3e-5 --epochs_num 3 --batch_size 32 --seq_length 512
最后,将预训练模型转换为 Huggingface 格式:
python3 scripts/convert_bert_text_classification_from_uer_to_huggingface.py --input_model_path models/chinanews_classifier_model.bin \
--output_model_path pytorch_model.bin \
--layers_num 12
引用信息
@article{liu2019roberta,
title={Roberta: A robustly optimized bert pretraining approach},
author={Liu, Yinhan and Ott, Myle and Goyal, Naman and Du, Jingfei and Joshi, Mandar and Chen, Danqi and Levy, Omer and Lewis, Mike and Zettlemoyer, Luke and Stoyanov, Veselin},
journal={arXiv preprint arXiv:1907.11692},
year={2019}
}
@article{zhang2017encoding,
title={Which encoding is the best for text classification in chinese, english, japanese and korean?},
author={Zhang, Xiang and LeCun, Yann},
journal={arXiv preprint arXiv:1708.02657},
year={2017}
}
@article{zhao2019uer,
title={UER: An Open-Source Toolkit for Pre-training Models},
author={Zhao, Zhe and Chen, Hui and Zhang, Jinbin and Zhao, Xin and Liu, Tao and Lu, Wei and Chen, Xi and Deng, Haotang and Ju, Qi and Du, Xiaoyong},
journal={EMNLP-IJCNLP 2019},
pages={241},
year={2019}
}
@article{zhao2023tencentpretrain,
title={TencentPretrain: A Scalable and Flexible Toolkit for Pre-training Models of Different Modalities},
author={Zhao, Zhe and Li, Yudong and Hou, Cheng and Zhao, Jing and others},
journal={ACL 2023},
pages={217},
year={2023}
Distilbert Base Uncased Finetuned Sst 2 English
Apache-2.0
基于DistilBERT-base-uncased在SST-2情感分析数据集上微调的文本分类模型,准确率91.3%
文本分类 英语
D
distilbert
5.2M
746
Xlm Roberta Base Language Detection
MIT
基于XLM-RoBERTa的多语言检测模型,支持20种语言的文本分类
文本分类
Transformers 支持多种语言

X
papluca
2.7M
333
Roberta Hate Speech Dynabench R4 Target
该模型通过动态生成数据集来改进在线仇恨检测,专注于从最差案例中学习以提高检测效果。
文本分类
Transformers 英语

R
facebook
2.0M
80
Bert Base Multilingual Uncased Sentiment
MIT
基于bert-base-multilingual-uncased微调的多语言情感分析模型,支持6种语言的商品评论情感分析
文本分类 支持多种语言
B
nlptown
1.8M
371
Emotion English Distilroberta Base
基于DistilRoBERTa-base微调的英文文本情感分类模型,可预测埃克曼六种基本情绪及中性类别。
文本分类
Transformers 英语

E
j-hartmann
1.1M
402
Robertuito Sentiment Analysis
基于RoBERTuito的西班牙语推文情感分析模型,支持POS(积极)/NEG(消极)/NEU(中性)三类情感分类
文本分类 西班牙语
R
pysentimiento
1.0M
88
Finbert Tone
FinBERT是一款基于金融通讯文本预训练的BERT模型,专注于金融自然语言处理领域。finbert-tone是其微调版本,用于金融情感分析任务。
文本分类
Transformers 英语

F
yiyanghkust
998.46k
178
Roberta Base Go Emotions
MIT
基于RoBERTa-base的多标签情感分类模型,在go_emotions数据集上训练,支持28种情感标签识别。
文本分类
Transformers 英语

R
SamLowe
848.12k
565
Xlm Emo T
XLM-EMO是一个基于XLM-T模型微调的多语言情感分析模型,支持19种语言,专门针对社交媒体文本的情感预测。
文本分类
Transformers 其他

X
MilaNLProc
692.30k
7
Deberta V3 Base Mnli Fever Anli
MIT
基于MultiNLI、Fever-NLI和ANLI数据集训练的DeBERTa-v3模型,擅长零样本分类和自然语言推理任务
文本分类
Transformers 英语

D
MoritzLaurer
613.93k
204
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98