bread-good111 commited on
Commit
061d280
·
verified ·
1 Parent(s): c93ad78

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -126
README.md DELETED
@@ -1,126 +0,0 @@
1
- # Emotion Detection Model - LongEmotion
2
-
3
- 情感检测模型,基于BERT的中文情感分类器
4
-
5
- ## 📊 模型信息
6
-
7
- - **基础模型**: bert-base-chinese
8
- - **任务类型**: 6分类情感检测
9
- - **验证准确率**: 91.47%
10
- - **框架**: PyTorch + Transformers
11
-
12
- ## 🏷️ 情感类别
13
-
14
- 模型可以识别以下6种情感:
15
- - `sadness` (悲伤)
16
- - `joy` (快乐)
17
- - `love` (爱)
18
- - `anger` (愤怒)
19
- - `fear` (恐惧)
20
- - `surprise` (惊讶)
21
-
22
- ## 📁 文件说明
23
-
24
- ```
25
- detection_hug/
26
- ├── model.pt # 模型权重文件
27
- ├── config.json # 模型配置
28
- ├── tokenizer_config.json # 分词器配置
29
- ├── vocab.txt # 词表
30
- ├── special_tokens_map.json # 特殊符号映射
31
- ├── detection_model.py # 模型定义
32
- ├── inference_example.py # 推理示例
33
- └── README.md # 本文件
34
- ```
35
-
36
- ## 🚀 快速开始
37
-
38
- ### 环境要求
39
-
40
- ```bash
41
- pip install torch transformers
42
- ```
43
-
44
- ### 基本使用
45
-
46
- ```python
47
- import torch
48
- from transformers import BertTokenizer
49
- from detection_model import EmotionDetectionModel
50
-
51
- # 1. 加载分词器
52
- tokenizer = BertTokenizer.from_pretrained(".")
53
-
54
- # 2. 加载模型
55
- model = EmotionDetectionModel(
56
- model_name="bert-base-chinese",
57
- num_emotions=6
58
- )
59
- checkpoint = torch.load("model.pt", map_location="cpu")
60
- model.load_state_dict(checkpoint)
61
- model.eval()
62
-
63
- # 3. 预测
64
- text = "我今天很开心!"
65
- encoding = tokenizer(text, return_tensors='pt', max_length=512, truncation=True, padding=True)
66
- outputs = model(**encoding)
67
- predicted_emotion = torch.argmax(outputs['logits'], dim=-1).item()
68
-
69
- # 情感映射
70
- emotions = ["sadness", "joy", "love", "anger", "fear", "surprise"]
71
- print(f"预测情感: {emotions[predicted_emotion]}")
72
- ```
73
-
74
- ### 使用推理脚本
75
-
76
- ```bash
77
- python inference_example.py
78
- ```
79
-
80
- ## 📈 模型性能
81
-
82
- - **数据集**: dair-ai/emotion (中文情感数据)
83
- - **验证准确率**: 91.47%
84
- - **平均置信度**: 89.27%
85
- - **最大序列长度**: 512 tokens
86
-
87
- ## 🔧 技术细节
88
-
89
- ### 模型架构
90
-
91
- ```
92
- EmotionDetectionModel
93
- ├── BERT Encoder (bert-base-chinese)
94
- │ └── 768-dim hidden states
95
- ├── Dropout (p=0.1)
96
- ├── Linear Layer (768 → 384)
97
- ├── ReLU Activation
98
- ├── Dropout (p=0.1)
99
- └── Output Layer (384 → 6)
100
- ```
101
-
102
- ### 训练参数
103
-
104
- - **优化器**: AdamW
105
- - **学习率**: 2e-5
106
- - **批次大小**: 16
107
- - **最大长度**: 512
108
-
109
- ## 📝 引用
110
-
111
- 如果您使用此模型,请注明:
112
- ```
113
- LongEmotion Detection Model
114
- - 基于 bert-base-chinese
115
- - 训练于 dair-ai/emotion 数据集
116
- ```
117
-
118
- ## 📧 联系方式
119
-
120
- 如有问题,请通过项目仓库联系。
121
-
122
- ---
123
-
124
- **License**: 遵循 bert-base-chinese 的许可协议
125
- **Created**: 2025
126
-