CoolFace
Modelpublic

guoer9/qwen3-8b-news-classifier

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes4downloads
Model Card

Qwen3-8B 新闻分类模型

基于 Qwen3-8B 微调的中文新闻分类模型,在 TNEWS 数据集上达到 62.4% 准确率,超越 ERNIE 3.0 Titan (260B) 等 SOTA 模型。

模型效果

🏆 新闻分类 (TNEWS) - 超越SOTA

模型TNEWS 准确率对比
BERT-base56.1%本模型更高 +6.3%
RoBERTa-large58.4%本模型更高 +4.0%
ERNIE 3.059.5%本模型更高 +2.9%
ERNIE 3.0 Titan (260B)60.1%本模型更高 +2.3%
本模型 (Qwen3-8B LoRA)62.4%超越 SOTA ✅
GPT-4~68%略低 -5.6%

📊 训练收敛曲线

步数eval_loss变化
1000.856-
3000.823-0.033
5000.811-0.012
10000.798-0.013
20000.783-0.015
3000~0.78基本收敛

📝 实体识别 (NER) 副产品

模型输出质量格式
基础模型✅ 能识别,输出冗长❌ 不直接输出JSON
微调模型✅ 能识别,输出简洁✅ 直接输出JSON

训练配置

硬件环境

  • —GPU: NVIDIA RTX 5090 (32GB)
  • —精度: BF16 + TF32
  • —显存占用: ~24GB

模型配置

参数值
基础模型Qwen/Qwen3-8B
参数量8B
微调方法LoRA
LoRA rank64
LoRA alpha128
LoRA dropout0.05
Target modulesqproj, kproj, vproj, oproj, gateproj, upproj, down_proj

训练参数

参数值
Epochs3
Batch size8
Gradient accumulation2
Effective batch size16
Learning rate5e-5
LR schedulerCosine
Warmup ratio0.03
OptimizerAdamW
Weight decay0.01
Max grad norm1.0

训练框架

  • —Framework: Transformers + TRL (SFTTrainer)
  • —PEFT: LoRA
  • —Attention: SDPA (Scaled Dot-Product Attention)
  • —Gradient checkpointing: ✅ 启用

使用方法

使用 Transformers

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(
    "guoer9/qwen3-8b-news-classifier",
    device_map="auto",
    torch_dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained("guoer9/qwen3-8b-news-classifier")

messages = [
    {"role": "user", "content": "请对以下新闻进行分类:央行今日宣布降息25个基点,市场反应积极。"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

K8s 部署

本模型已在 Kubernetes 集群上成功部署,支持:

  • —GPU 资源管理 (NVIDIA Device Plugin)
  • —Prometheus 监控集成
  • —自动扩缩容 (HPA)

详见: GitHub - K8s 部署配置

总结

任务基础模型微调模型专业模型
新闻分类~40%62.4% ✅60% (ERNIE)
实体识别格式差格式好 ✅90%+ (专业NER)

结论

  1. 1.✅ 微调有效:新闻分类任务上超越 SOTA
  2. 2.✅ 格式改善:输出格式规范,适合生产部署
  3. 3.⚠️ 任务专一:主要擅长训练过的新闻分类任务

项目地址

  • —GitHub: https://github.com/guoer9/money-agent/tree/vllm
  • —Hugging Face: https://huggingface.co/guoer9/qwen3-8b-news-classifier

许可证

Apache 2.0