Views
No views yet
YiMeng-SYSU/chinese-logic-sentiment-dataset (Generated by Doubao API)Golden Test Set (960 samples) is as follows:| Metric | Score |
|---|---|
| Accuracy | 96.15% |
| Macro-F1 | 96.00% |
| Recall (Negative) | 97.53% |
| Recall (Positive) | 94.15% |
| Type | Accuracy | Note |
|---|---|---|
| Simple (简单句) | 97.50% | 基础稳固 |
| Transition (转折) | 97.03% | 完美理解转折逻辑 |
| Double Neg (双重否定) | 96.67% | 彻底解决"双重否定表肯定/否定"的歧义 |
| Irony (反讽) | 92.47% | 核心亮点:具备识别"反话正说"的能力 |
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3model_name = "YiMeng-SYSU/roberta-logic-sentiment-zh"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSequenceClassification.from_pretrained(model_name)
6text = "这部剧简直有毒,害得我昨晚又熬到凌晨三点,黑眼圈都出来了!"
7inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512) # 补充tokenizer参数,更健壮
8with torch.no_grad():
9 outputs = model(**inputs)
10 probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
11# 结合config中的id2label映射,输出可读标签(而非数字)
12id2label = {0: "Negative (负面)", 1: "Positive (正面)"}
13pred_label_id = torch.argmax(probs).item()
14print(f"Label: {id2label[pred_label_id]}")
15print(f"Confidence: {probs.max().item():.4f}")