---
title: nlp_style_classification_english
canonical_url: "https://www.modelscope.cn/models/damo/nlp_style_classification_english"
md_url: "https://www.modelscope.cn/models/damo/nlp_style_classification_english.md"
repository: damo/nlp_style_classification_english
chinese_name: "FastTex文本文风分类-英文-四类文风"
last_updated: 2022-10-11
pipeline_tag: text-classification
tasks:
  - text-classification
library_name:
  - pytorch
frameworks:
  - pytorch
downloads: 284
stars: 4
---

# nlp_style_classification_english

> nlp_style_classification_english - damo 在 ModelScope 开源的模型。用于英文句子的文风判别，支持新闻/口语/科技/电商四类文风的分类。

- **Repository**: damo/nlp_style_classification_english
- **Tasks**: text-classification
- **Downloads**: 284
- **Stars**: 4
- **Last updated**: 2022-10-11

Source: https://www.modelscope.cn/models/damo/nlp_style_classification_english

---

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

# 文本文风分类-英文
用于英文句子的文风分类，支持以下四类文风：

| 文风标签 | 含义                                   |
|----------|----------------------------------------|
| news     | 新闻文风，即各类常用的书面语           |
| tech     | 科技文风，包括技术文档、科技文献等     |
| spoken   | 口语文风，各类非书面的口语表达         |
| ecomm    | 电商文风，电商场景的标题、评论、描述等 |


## 模型描述

该模型基于FastText训练，无需GPU即可进行高效推理，训练数据为阿里内部数据，在内部测试集上，4类文风平均分类准确率为90.83%。

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


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

#### 代码范例
<!--- 本session里的python代码段，将被ModelScope模型页面解析为快速开始范例--->
```python
from modelscope.pipelines import pipeline
p = pipeline('text-classification', model='damo/nlp_style_classification_english')
print(p('High Power 11.1V 5200mAh Lipo Battery For RC Car Robot Airplanes Helicopter RC Drone Parts 3s Lithium battery 11.1v Battery'))

```

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

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

## 模型训练流程
基于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 |
|-------:|:---------:|:------:|:--------:|
| ecomm |   99.65   | 99.60 |  99.62  |
| spoken |   86.29   | 84.35  |  85.31   |
| news |   85.29   | 87.25  |  86.26   |
| tech |   92.10   | 92.10  |  92.10   |
