---
title: nlp_domain_classification_chinese
canonical_url: "https://www.modelscope.cn/models/iic/nlp_domain_classification_chinese"
md_url: "https://www.modelscope.cn/models/iic/nlp_domain_classification_chinese.md"
repository: iic/nlp_domain_classification_chinese
chinese_name: "FastText文本领域分类-中文-国民经济行业18大类"
last_updated: 2022-10-11
license: "Apache License 2.0"
pipeline_tag: text-classification
tasks:
  - text-classification
library_name:
  - pytorch
frameworks:
  - pytorch
language:
  - cn
domain:
  - multi-modal
downloads: 15149
stars: 44
tags:
  - fasttext
  - Alibaba
  - domain-classification
---

# nlp_domain_classification_chinese

> nlp_domain_classification_chinese - iic 在 ModelScope 开源的模型。用于中文的文本领域分类，分类依据为国民经济行业分类（GB/T 4754—2017），原分类标准有20大类，目前支持18个行业的分类：交通运输仓储邮政\住宿餐饮\信息软件\农业\制造业\卫生医疗\国际组织\建筑\房地产\政府组织\教育\文体娱乐\水利环境\电力燃气水生产\科学技术\租赁法律\采矿\金融。

iic/nlp_domain_classification_chinese 是 ModelScope 魔搭社区上的text-classification模型，采用 Apache License 2.0 许可。

- **Repository**: iic/nlp_domain_classification_chinese
- **License**: Apache License 2.0
- **Tasks**: text-classification
- **Tags**: fasttext, Alibaba, domain-classification
- **Downloads**: 15149
- **Stars**: 44
- **Last updated**: 2022-10-11

Source: https://www.modelscope.cn/models/iic/nlp_domain_classification_chinese

---

<!--- 以下model card模型说明部分，请使用中文提供（除了代码，bibtex等部分） --->

# 文本领域分类-中文
用于中文的文本领域分类。分类依据为国民经济行业分类（GB/T 4754—2017），基本覆盖了国民经济全行业，共支持18个大类行业的分类：交通运输仓储邮政、住宿餐饮、信息软件、农业、制造业、卫生医疗、国际组织、建筑、房地产、政府组织、教育、文体娱乐、水利环境、电力燃气水生产、科学技术、租赁法律、采矿、金融。
每个领域的具体内容，详见《2017年国民经济行业分类（GB/T 4754—2017）》。

## 模型描述

该模型基于FastText训练，无需GPU即可进行高效推理，训练数据为阿里内部数据，在内部测试集上，18个行业平均分类准确率为63.44%，Top 3命中率（Recall@3）为80.64%。

## 期望模型使用方式以及适用范围
该模型可用于中文句子级别的领域分类，分类结果可用于模型选择、数据分析等。


### 如何使用
在安装ModelScope完成后即可使用

#### 代码范例
<!--- 本session里的python代码段，将被ModelScope模型页面解析为快速开始范例--->
```python
from modelscope.pipelines import pipeline
p = pipeline('text-classification', model='damo/nlp_domain_classification_chinese')
print(p('通过这种方式产生的离子吸收大地水分之后,可以通过潮解作用,将活性电解离子有效释放到周围土壤中,使接地极成为一个离子发生装置,从而改善周边土质使之达到接地要求。'))

```

### 模型局限性以及可能的偏差
通常单个句子的领域信息很难明确，建议作为句子级分类工具，对输出概率在篇章或者段落级聚合，会更为准确

## 训练数据介绍
源自阿里内部数据

## 模型训练流程
基于FastText训练

### 预处理
采用sentencepiece进行分词，并和label进行拼接

```bash
spm_encode --model ./sentencepiece.model < train.text > train.sp
paste -d ' ' train.label train.sp > train.input
```

### 训练
基于CPU训练即可

```bash
fastText/fasttext supervised -dim 256 -wordNgrams 3  -epoch 3 -thread 32 \
        -input train.input \
        -output savedModel
````

## 数据评估及结果
模型在内部测试集上的评估结果

|            label | Precision | Recall | F1-score |
|-----------------:|:---------:|:------:|:--------:|
| 交通运输仓储邮政 |   67.77   | 67.33  |  67.55   |
|         住宿餐饮 |   78.78   | 85.82  |  82.15   |
|         信息软件 |   67.22   | 62.49  |  64.77   |
|             农业 |   71.91   | 79.68  |  75.60   |
|           制造业 |   64.70   | 60.28  |  62.41   |
|         卫生医疗 |   69.06   | 83.86  |  75.74   |
|         国际组织 |   83.15   | 88.72  |  85.85   |
|             建筑 |   80.96   | 66.92  |  73.27   |
|           房地产 |   46.99   | 29.29  |  36.08   |
|         政府组织 |   28.46   | 38.44  |  32.71   |
|             教育 |   63.00   | 64.67  |  63.82   |
|         文体娱乐 |   47.32   | 38.61  |  42.52   |
|         水利环境 |   52.28   | 54.35  |  53.30   |
|   电力燃气水生产 |   58.60   | 68.42  |  63.13   |
|         科学技术 |   71.20   | 72.09  |  71.64   |
|         租赁法律 |   62.40   | 59.47  |  60.90   |
|             采矿 |   58.48   | 54.82  |  56.59   |
|             金融 |   73.20   | 66.81  |  69.86   |


平均Recall@K

| K        | 1      | 2      | 3      | 4      | 5      | 6      | 7      | 8      | 9      | 10     | 11     | 12     | 13     | 14     | 15     | 16     | 17     | 18      |
|----------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|---------|
| Recall@K | 63.44  | 74.68  | 80.64  | 84.69  | 87.69  | 90.14  | 92.04  | 93.56  | 94.92  | 96.00  | 96.88  | 97.68  | 98.31  | 98.90  | 99.40  | 99.70  | 99.90  | 100.00  |
