---
title: goods_text_classification
canonical_url: "https://www.modelscope.cn/models/SDT/goods_text_classification"
md_url: "https://www.modelscope.cn/models/SDT/goods_text_classification.md"
repository: SDT/goods_text_classification
chinese_name: "商品文本信息分类模型"
last_updated: 2026-01-28
license: "Apache License 2.0"
pipeline_tag: text-classification
tasks:
  - text-classification
model_type:
  - bert
architectures:
  - BertForSequenceClassification
parameters: 102.3M
tensor_type:
  - F32
library_name:
  - pytorch
  - transformer
  - safetensors
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task emb"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 73
stars: 1
---

# goods_text_classification

> goods_text_classification - SDT 在 ModelScope 开源的模型。上传一个商品文本，输出商品类别，现阶段支持类别分为6类，分别为：'关键卖点', '规格', '服务承诺', '品牌Logo名称', '产品名称', '产品核心参数'

SDT/goods_text_classification 是 ModelScope 魔搭社区上的 102.3M 参数text-classification模型，采用 Apache License 2.0 许可，可用 deploy_task emb、sglang 0.5.2、vllm 0.9.2 部署。

- **Repository**: SDT/goods_text_classification
- **License**: Apache License 2.0
- **Tasks**: text-classification
- **Parameters**: 102.3M
- **Inference backends**: deploy_task emb, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 73
- **Stars**: 1
- **Last updated**: 2026-01-28

Source: https://www.modelscope.cn/models/SDT/goods_text_classification

---

一个简单的测试脚本

import os
import torch
from transformers import BertTokenizer, BertForSequenceClassification

# 模型路径
MODEL_PATH = r"you_path"

# 加载模型和分词
tokenizer = BertTokenizer.from_pretrained(MODEL_PATH)
model = BertForSequenceClassification.from_pretrained(MODEL_PATH)
model.eval()

# 获取标签映射
id2label = model.config.id2label
print(f"模型支持的类别：{list(id2label.values())}")


def predict(text: str) -> str:
    inputs = tokenizer(
        text,
        return_tensors="pt",
        truncation=True,
        padding=True,
        max_length=128
    )
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        predicted_class_id = logits.argmax().item()
        predicted_label = id2label[predicted_class_id]
    return predicted_label


if __name__ == "__main__":
    test_texts = [
        "这是一款高性能的游戏笔记本电脑，配备RTX 4070显卡",
        "纯棉男士短袖T恤，夏季透气舒适",
        "智能扫地机器人，自动规划路径，强力吸尘"
    ]

    for text in test_texts:
        pred = predict(text)
        print(f"输入: {text}")
        print(f"预测类别: {pred}\n")

    # 交互式测试
    while True:
        user_input = input("请输入要分类的文本: ").strip()
        if user_input.lower() == 'quit':
            break
        if user_input:
            result = predict(user_input)
            print(f"预测类别: {result}\n")
SDK下载
```bash
#安装ModelScope
pip install modelscope
```
```python
#SDK模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('SdtDevAi/goods_text_classification')
```
Git下载
```
#Git模型下载
git clone https://www.modelscope.cn/SdtDevAi/goods_text_classification.git
```

<p style="color: lightgrey;">如果您是本模型的贡献者，我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>，及时完善模型卡片内容。</p>
