File size: 1,433 Bytes
ba75e44 418f4fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
---
language:
- zh
tags:
- pytorch
- zh
---
[hfl/chinese-roberta-wwm-ext](https://huggingface.co/hfl/chinese-roberta-wwm-ext) fine-tuned on the [COLDataset](https://github.com/thu-coai/COLDataset). Usage example:
```python
import torch
from transformers.models.bert import BertTokenizer, BertForSequenceClassification
tokenizer = BertTokenizer.from_pretrained('thu-coai/roberta-base-cold')
model = BertForSequenceClassification.from_pretrained('thu-coai/roberta-base-cold')
model.eval()
texts = ['你就是个傻逼!','黑人很多都好吃懒做,偷奸耍滑!','男女平等,黑人也很优秀。']
model_input = tokenizer(texts,return_tensors="pt",padding=True)
model_output = model(**model_input, return_dict=False)
prediction = torch.argmax(model_output[0].cpu(), dim=-1)
prediction = [p.item() for p in prediction]
print(prediction) # --> [1, 1, 0] (0 for Non-Offensive, 1 for Offenisve)
```
This fine-tuned model obtains 82.75 accuracy and 82.39 macro-F1 on the test set.
Please kindly cite the [original paper](https://arxiv.org/abs/2201.06025) if you use this model.
```
@article{deng2022cold,
title={Cold: A benchmark for chinese offensive language detection},
author={Deng, Jiawen and Zhou, Jingyan and Sun, Hao and Zheng, Chujie and Mi, Fei and Meng, Helen and Huang, Minlie},
booktitle={Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing},
year={2022}
}
```
|