基于别人的代码.
BERT参考:https://github.com/huggingface/pytorch-pretrained-BERT
pytorch-pretrained-BERT
是一个基于Pytorch
的封装好的BERT框架,使用其中的BertForSequenceClassification
。
训练:
数据格式:
每一个行为一个json字符串,json字符串内有label
、text
字段。
label
字段与train.py的MyPro.get_labels()
对应。
数据格式:json list,每一个元素长度不超过120字符,超过后自动截断,list长度不超过32.
返回数据:json list,顺序对应请求的list顺序,包含label
、scores
字段
训练数据集来源:https://github.com/SophonPlus/ChineseNlpCorpus/blob/master/datasets/weibo_senti_100k/intro.ipynb
将数据5:3:2拆分为train、valid、test,test集上效果:F1=0.9755794284298703