Create README.md
Browse files
README.md
CHANGED
|
@@ -1,23 +1,40 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
| 3 |
tags:
|
| 4 |
-
- pytorch
|
| 5 |
-
- text-classification
|
| 6 |
-
- sentiment-analysis
|
| 7 |
-
- chinese
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
# Tiny Sentiment Classifier
|
| 11 |
|
| 12 |
-
一个非常小的 Transformer 模型,用于中文情感二分类(正面/负面)。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
## 使用方式
|
| 15 |
|
| 16 |
```python
|
| 17 |
from transformers import pipeline
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
| 22 |
result = classifier(text)
|
| 23 |
-
print(result)
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
library_name: transformers
|
| 4 |
tags:
|
| 5 |
+
- pytorch
|
| 6 |
+
- text-classification
|
| 7 |
+
- sentiment-analysis
|
| 8 |
+
- chinese
|
| 9 |
+
pipeline_tag: text-classification
|
| 10 |
+
language: zh
|
| 11 |
---
|
| 12 |
|
| 13 |
# Tiny Sentiment Classifier
|
| 14 |
|
| 15 |
+
这是一个非常小的自定义 Transformer 模型,用于**中文情感二分类**(正面/负面)。
|
| 16 |
+
|
| 17 |
+
## 模型简介
|
| 18 |
+
|
| 19 |
+
- 架构:小型 Transformer Encoder + 线性分类头
|
| 20 |
+
- 隐藏维度:128
|
| 21 |
+
- 层数:2
|
| 22 |
+
- 词汇表:字符级(支持中文汉字 + ASCII)
|
| 23 |
+
- 训练数据:极简玩具数据集(仅用于演示 HF 适配流程)
|
| 24 |
|
| 25 |
## 使用方式
|
| 26 |
|
| 27 |
```python
|
| 28 |
from transformers import pipeline
|
| 29 |
|
| 30 |
+
# 加载模型
|
| 31 |
+
classifier = pipeline(
|
| 32 |
+
"text-classification",
|
| 33 |
+
model="huiqian/tiny-sentiment-classifier"
|
| 34 |
+
)
|
| 35 |
|
| 36 |
+
# 预测
|
| 37 |
+
text = "这家店的服务超级好,强烈推荐!"
|
| 38 |
result = classifier(text)
|
| 39 |
+
print(result)
|
| 40 |
+
# 示例输出: [{'label': '正面', 'score': 0.98}]
|