chujiezheng commited on
Commit
418f4fe
1 Parent(s): 073acfa

Create README.md

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