Qwen3-8B 新闻分类模型

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

模型效果

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

模型 TNEWS 准确率 对比
BERT-base 56.1% 本模型更高 +6.3%
RoBERTa-large 58.4% 本模型更高 +4.0%
ERNIE 3.0 59.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 变化
100 0.856 -
300 0.823 -0.033
500 0.811 -0.012
1000 0.798 -0.013
2000 0.783 -0.015
3000 ~0.78 基本收敛

📝 实体识别 (NER) 副产品

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

训练配置

硬件环境

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

模型配置

参数
基础模型 Qwen/Qwen3-8B
参数量 8B
微调方法 LoRA
LoRA rank 64
LoRA alpha 128
LoRA dropout 0.05
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj

训练参数

参数
Epochs 3
Batch size 8
Gradient accumulation 2
Effective batch size 16
Learning rate 5e-5
LR scheduler Cosine
Warmup ratio 0.03
Optimizer AdamW
Weight decay 0.01
Max grad norm 1.0

训练框架

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

使用方法

使用 Transformers

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

项目地址

许可证

Apache 2.0

Downloads last month
5
Safetensors
Model size
8B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for guoer9/qwen3-8b-news-classifier

Finetuned
Qwen/Qwen3-8B
Adapter
(2050)
this model