Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
2
3MODEL = "tezign/Erlangshen-Sentiment-FineTune"
4
5tokenizer = AutoTokenizer.from_pretrained(MODEL)
6
7model = AutoModelForSequenceClassification.from_pretrained(MODEL, trust_remote_code=True)
8
9classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
10
11result = classifier("很好,干净整洁,交通方便。")
12
13print(result)
14
15"""
16print result
17>> [{'label': 'Positive', 'score': 0.989660382270813}]
18"""1Our finetune model:
2 precision recall f1-score support
3
4 Negative 0.99 0.98 0.98 5429
5 Positive 0.92 0.95 0.93 1251
6
7 accuracy 0.97 6680
8 macro avg 0.95 0.96 0.96 6680
9weighted avg 0.97 0.97 0.97 6680
10
11======================================================
12
13Original Erlangshen model:
14 precision recall f1-score support
15
16 Negative 0.81 1.00 0.90 5429
17 Positive 0.00 0.00 0.00 1251
18
19 accuracy 0.81 6680
20 macro avg 0.41 0.50 0.45 6680
21weighted avg 0.66 0.81 0.73 6680