traffic-classify / README.md
pawizard's picture
Upload traffic classifier with ONNX exports
aa7739c verified
|
Raw
History Blame Contribute Delete
1.91 kB
---
language:
- zh
pipeline_tag: text-classification
tags:
- chinese
- text-classification
- onnx
- intent-classification
library_name: transformers
---
# traffic-classify
Chinese text classifier for traffic / intent classification into three labels:
- `0`: 非研发相关
- `1`: 研发相关
- `2`: 中性
## Files
- Root directory: Transformers model, tokenizer, and config.
- `onnx/model_fp32.onnx`: FP32 ONNX export.
- `onnx/model_int8.onnx`: INT8 quantized ONNX model for CPU inference.
## Evaluation
On the held-out evaluation set, the classifier achieves an overall accuracy of
approximately `94%`, with a weighted F1-score of approximately `94%`,
demonstrating strong classification capability across different traffic types.
The per-class F1-scores are:
- 研发相关: `0.96`
- 中性: `0.93`
- 非研发相关: `0.88`
The results indicate that the model performs particularly well in identifying
研发-related traffic, while non-研发 traffic remains relatively more
challenging due to semantic overlap with technical discussions.
## Dataset Policy
The dataset uses a compact three-class policy:
- 研发相关: full software / IT / electronics / communication terminology sources.
- 中性: stopwords only.
- 非研发相关: remaining dictionary categories, compactly sampled.
See the project `DATA_SOURCES.md` for source details.
## Usage
```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
repo_id = "pawizard/traffic-classify"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
text = "这个 NullPointerException 报错怎么修复"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
pred = int(logits.argmax(dim=-1).item())
print(model.config.id2label[pred])
```