BERT Chinese SMS Travel Classifier
模型描述
這是一個基於 ckiplab/bert-base-chinese
微調的中文 BERT 模型,專門用於對 SMS 簡訊進行旅遊相關內容的二元分類。
模型用途
- 任務: 文本分類 (Text Classification)
- 語言: 中文 (Chinese)
- 領域: SMS 簡訊、旅遊
- 分類: 二元分類 (旅遊相關 vs 非旅遊相關)
性能表現
指標 | 數值 |
---|---|
驗證準確率 | 1.0000 |
最佳準確率 | 1.0000 |
訓練資料
- 訓練集大小: 6400 筆
- 驗證集大小: 800 筆
- 測試集大小: 801 筆
使用方法
from transformers import BertTokenizer, BertForSequenceClassification
import torch
# 載入模型和分詞器
model_name = "renhehuang/bert-chinese-sms-travel-classifier"
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertForSequenceClassification.from_pretrained(model_name)
# 預測函數
def predict_sms(text, max_length=256):
model.eval()
encoding = tokenizer.encode_plus(
text,
add_special_tokens=True,
max_length=max_length,
return_token_type_ids=False,
padding='max_length',
truncation=True,
return_attention_mask=True,
return_tensors='pt'
)
with torch.no_grad():
outputs = model(
input_ids=encoding['input_ids'],
attention_mask=encoding['attention_mask']
)
logits = outputs.logits
probabilities = torch.softmax(logits, dim=-1)
predicted_class = torch.argmax(logits, dim=-1).item()
confidence = probabilities[0][predicted_class].item()
return predicted_class, confidence
# 使用範例
text = "【可樂旅遊】歐洲浪漫10日遊即將出發!"
predicted_class, confidence = predict_sms(text)
print(f"預測類別: {predicted_class} (信心度: {confidence:.4f})")
訓練配置
- 基礎模型: ckiplab/bert-base-chinese
- 訓練週期: 5 epochs
- 批次大小: 8
- 學習率: 3e-05
- 最大序列長度: 256
- 訓練設備: mps
- 早停機制: 未啟用
特殊優化
✅ Apple Silicon 優化: 此模型針對 Apple Silicon (M1/M2/M3) 晶片進行了特別優化,包括 MPS GPU 加速和記憶體優化。
標籤說明
0
: 非旅遊相關1
: 旅遊相關
限制和注意事項
- 此模型專門針對中文 SMS 簡訊文本進行訓練
- 最佳性能表現在長度不超過 256 個 token 的文本上
- 主要適用於繁體中文內容
- 在簡體中文上的表現可能略有差異
引用
如果您使用了此模型,請引用:
@misc{bert-chinese-sms-travel-classifier,
title={BERT Chinese SMS Travel Classifier},
author={renhehuang},
year={2025},
publisher={Hugging Face},
journal={Hugging Face Model Hub},
}
聯絡資訊
如有問題或建議,請通過 Hugging Face 或 GitHub 聯絡作者。
- Downloads last month
- 13
Evaluation results
- Accuracy on SMS Travel Classificationself-reported1.000