README.md 3.3 KB
Newer Older
Z
Zeyu Chen 已提交
1 2
简体中文 | [English] (./README_en.md)

Z
Zeyu Chen 已提交
3
# PaddleNLP
4

Z
Zeyu Chen 已提交
5 6 7
![License](https://img.shields.io/badge/license-Apache%202-red.svg)
![python version](https://img.shields.io/badge/python-3.6+-orange.svg)
![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg)
8

Z
Zeyu Chen 已提交
9
## Introduction
10

Z
Zeyu Chen 已提交
11
PaddleNLP aims to accelerate NLP applications through powerful model zoo, easy-to-use API with detailed tutorials, It's also the NLP best practice for PaddlePaddle 2.0 API system.
P
pkpk 已提交
12

Z
Zeyu Chen 已提交
13
**This project is still UNDER ACTIVE DEVELOPMENT.**
P
pkpk 已提交
14

Z
Zeyu Chen 已提交
15
## Features
P
pkpk 已提交
16

Z
Zeyu Chen 已提交
17 18 19 20 21 22 23 24
* **Rich and Powerful Model Zoo**
  - Our Model Zoo covers mainstream NLP applications, including Lexical Analysis, Syntactic Parsing, Machine Translation, Text Classification, Text Generation, Text Matching, General Dialogue and Question Answering etc.
* **Easy-to-use API**
  - The API is fully integrated with PaddlePaddle high-level API system. It minimizes the number of user actions required for common use cases like data loading, text pre-processing, training and evaluation. which enables you to deal with text problems more productively.
* **High Performance and Large-scale Training**
  - We provide a highly optimized ditributed training implementation for BERT with Fleet API, it can fully utilize GPU clusters for large-scale model pre-training. Please refer to our [benchmark](./benchmark/bert) for more information.
* **Detailed Tutorials and Industrial Practices**
  - We offers detailed and interactable notebook tutorials to show you the best practices of PaddlePaddle 2.0.
P
pkpk 已提交
25

Z
Zeyu Chen 已提交
26
## Installation
P
pkpk 已提交
27

Z
Zeyu Chen 已提交
28
### Prerequisites
P
pkpk 已提交
29

Z
Zeyu Chen 已提交
30 31
* python >= 3.6
* paddlepaddle >= 2.0.0-rc1
P
pkpk 已提交
32

Z
Zeyu Chen 已提交
33
```
Z
Zeyu Chen 已提交
34
pip install paddlenlp>=2.0.0a
Z
Zeyu Chen 已提交
35
```
P
pkpk 已提交
36

Z
Zeyu Chen 已提交
37
## Quick Start
P
pkpk 已提交
38

Z
Zeyu Chen 已提交
39
### Quick Dataset Loading
P
pkpk 已提交
40

Z
Zeyu Chen 已提交
41
```python
Z
Zeyu Chen 已提交
42
from paddlenlp.datasets import ChnSentiCrop
Z
Zeyu Chen 已提交
43

Z
Zeyu Chen 已提交
44
train_ds, test_ds = ChnSentiCorp.get_datasets(['train','test'])
P
pkpk 已提交
45 46
```

Z
Zeyu Chen 已提交
47
### Chinese Text Emebdding Loading
P
pkpk 已提交
48

Z
Zeyu Chen 已提交
49
```python
Z
Zeyu Chen 已提交
50 51

from paddlenlp.embeddings import TokenEmbedding
Z
Zeyu Chen 已提交
52

Z
Zeyu Chen 已提交
53 54 55 56 57
wordemb = TokenEmbedding("w2v.baidu_encyclopedia.target.word-word.dim300")
print(wordemb.cosine_sim("国王", "王后"))
>>> 0.63395125
wordemb.cosine_sim("艺术", "火车")
>>> 0.14792643
Z
Zeyu Chen 已提交
58
```
Z
Zeyu Chen 已提交
59

Z
Zeyu Chen 已提交
60 61 62 63
### One-Line Classical Model Building

```python
from paddlenlp.models import Ernie
Z
Zeyu Chen 已提交
64

Z
Zeyu Chen 已提交
65 66
ernie = Ernie(Ernie.Task.SeqCls)
ernie.forward(input_ids, segment_ids)
P
pkpk 已提交
67 68
```

Z
Zeyu Chen 已提交
69
### Rich Chinsese Pre-trained Models
P
pkpk 已提交
70

Z
Zeyu Chen 已提交
71
```python
Z
Zeyu Chen 已提交
72
from paddlenlp.transformers import ErnieModel, BertModel, RobertaModel, ElectraModel
Z
Zeyu Chen 已提交
73

Z
Zeyu Chen 已提交
74
ernie = ErnieModel.from_pretrained('ernie-1.0')
Z
Zeyu Chen 已提交
75
bert = BertModel.from_pretrained('bert-wwm-chinese')
Z
Zeyu Chen 已提交
76
roberta = RobertaModel.from_pretrained('roberta-wwm-ext')
Z
Zeyu Chen 已提交
77
electra = ElectraModel.from_pretrained('chinese-electra-small')
Y
Yibing Liu 已提交
78 79
```

Z
Zeyu Chen 已提交
80 81
For more pretrained model selection, please refer to [PretrainedModels](./paddlenlp/transformers/README.md)

Z
Zeyu Chen 已提交
82 83
## API Usage

Z
Zeyu Chen 已提交
84 85 86 87 88
* [Transformer API](./docs/transformers.md)
* [Dataset API](./docs/datasets.md)
* [Embedding API](./docs/embeddings.md)
* [Metrics API](./docs/embeddings.md)
* [Models API](./docs/models.md)
Z
Zeyu Chen 已提交
89

Z
Zeyu Chen 已提交
90 91
## Tutorials

Z
Zeyu Chen 已提交
92
Please refer to our official AI Studio account for more interactive tutorials: [PaddleNLP on AI Studio](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/574995)
Y
Yibing Liu 已提交
93

Z
Zeyu Chen 已提交
94
## Community
Y
Yibing Liu 已提交
95

Z
Zeyu Chen 已提交
96 97
* SIG for Pretrained Model Contribution
* SIG for Dataset Integration
Z
Zeyu Chen 已提交
98
* SIG for Tutorial Writing
Y
Yibing Liu 已提交
99

Z
Zeyu Chen 已提交
100
## License
Y
Yibing Liu 已提交
101

Z
Zeyu Chen 已提交
102
PaddleNLP is provided under the [Apache-2.0 License](./LICENSE).