Views
No views yet
bert-base-chinese for sentiment analysis in the specific domain of Chinese herbal medicine e-commerce reviews. It is designed to classify customer reviews into three sentiment categories: Negative (0), Neutral (1), and Positive (2).transformers library:1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("1hugh/Herbal-Sentiment-BERT")
4model = AutoModelForSequenceClassification.from_pretrained("1hugh/Herbal-Sentiment-BERT")
5
6text = "这当归发霉了,味道极差!"
7inputs = tokenizer(text, return_tensors="pt")
8
9outputs = model(**inputs)
10predictions = outputs.logits.argmax(dim=-1)
11
12# Labels: 0 -> Negative, 1 -> Neutral, 2 -> Positive
13print(f"Predicted class: {predictions.item()}")