Views
No views yet
负面 / 正面1LABEL_0 / 负面 = 负面
2LABEL_1 / 正面 = 正面uer/chinese_roberta_L-8_H-512waimai_10k,整理后数据规模为:1训练集:9584 条
2验证集:1198 条
3测试集:1198 条1text,label
2配送很快,味道也不错,1
3等了两个小时,菜都凉了,0waimai_10k_test.csv 上的测试结果:1accuracy: 0.9115
2macro_precision: 0.9044
3macro_recall: 0.8949
4macro_f1: 0.89941负面 precision 0.9240 | recall 0.9449 | f1 0.9343 | support 798
2正面 precision 0.8848 | recall 0.8450 | f1 0.8645 | support 4001 pred_负面 pred_正面
2true_负面 754 44
3true_正面 62 3381from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4model_name = "hax404/cn-transformer-sentiment"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9text = "配送很快,味道也不错"
10inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
11
12with torch.no_grad():
13 logits = model(**inputs).logits
14 probs = torch.softmax(logits, dim=-1)[0]
15 pred = int(torch.argmax(probs))
16
17print(model.config.id2label[pred], float(probs[pred]))1味道不错,但是送餐太慢
2送得挺快,就是饮料送错了
3有点腻,味道还可以