Skip to content

Commit

Permalink
[PaddleNLP 3.0] Refactor examples (#8609)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrownFish19 committed Jun 18, 2024
1 parent c134a7f commit 307960c
Show file tree
Hide file tree
Showing 571 changed files with 1,419 additions and 40,620 deletions.
5 changes: 2 additions & 3 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
**A:** 通过使用PaddleNLP提供的 `load_dataset``MapDataset``IterDataset` ,可以方便的自定义属于自己的数据集哦,也欢迎您贡献数据集到PaddleNLP repo。

从本地文件创建数据集时,我们 **推荐** 根据本地数据集的格式给出读取function并传入 `load_dataset()` 中创建数据集。
[waybill_ie](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction/waybill_ie)快递单信息抽取任务中的数据为例:

```python
from paddlenlp.datasets import load_dataset
Expand Down Expand Up @@ -368,12 +367,12 @@ model.set_state_dict(paddle.load("xxx_para"))
动转静,即将动态图的模型转为可用于部署的静态图模型。
动态图接口更加易用,python 风格的交互式编程体验,对于模型开发更为友好,而静态图相比于动态图在性能方面有更绝对的优势。因此动转静提供了这样的桥梁,同时兼顾开发成本和性能。
可以参考官方文档 [动态图转静态图文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/04_dygraph_to_static/index_cn.html),使用 `paddle.jit.to_static` 完成动转静。
另外,在 PaddleNLP 我们也提供了导出静态图模型的例子,可以参考 [waybill_ie 模型导出](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction/waybill_ie/#%E6%A8%A1%E5%9E%8B%E5%AF%BC%E5%87%BA)
另外,在 PaddleNLP 我们也提供了导出静态图模型的例子。

2)借助Paddle Inference部署

动转静之后保存下来的模型可以借助Paddle Inference完成高性能推理部署。Paddle Inference内置高性能的CPU/GPU Kernel,结合细粒度OP横向纵向融合等策略,并集成 TensorRT 实现模型推理的性能提升。具体可以参考文档 [Paddle Inference 简介](https://paddleinference.paddlepaddle.org.cn/master/product_introduction/inference_intro.html)。
为便于初次上手的用户更易理解 NLP 模型如何使用Paddle Inference,PaddleNLP 也提供了对应的例子以供参考,可以参考 [/PaddleNLP/examples](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/) 下的deploy目录,如[基于ERNIE的命名实体识别模型部署](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction/waybill_ie/deploy/python)
为便于初次上手的用户更易理解 NLP 模型如何使用Paddle Inference,PaddleNLP 也提供了对应的例子以供参考,可以参考 [/PaddleNLP/examples](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/) 下的deploy目录。

<a name="5-2"></a>

Expand Down
4 changes: 1 addition & 3 deletions docs/data_prepare/dataset_self_defined.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

从本地文件创建数据集时,我们 **推荐** 根据本地数据集的格式给出读取function并传入 :func:`load_dataset` 中创建数据集。

以 `waybill_ie <https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction/waybill_ie>`__ 快递单信息抽取任务中的数据为例:

.. code-block::
from paddlenlp.datasets import load_dataset
Expand Down Expand Up @@ -44,7 +42,7 @@
:class:`paddle.io.Dataset/IterableDataset` 创建数据集
-------------------

虽然PaddlePddle内置的 :class:`Dataset` 和 :class:`IterableDataset` 是可以直接接入 :class:`DataLoader` 用于模型训练的,但有时我们希望更方便的使用一些数据处理(例如convert to feature, 数据清洗,数据增强等)。而PaddleNLP内置的 :class:`MapDataset` 和 :class:`IterDataset` 正好提供了能实现以上功能的API。
虽然PaddlePaddle内置的 :class:`Dataset` 和 :class:`IterableDataset` 是可以直接接入 :class:`DataLoader` 用于模型训练的,但有时我们希望更方便的使用一些数据处理(例如convert to feature, 数据清洗,数据增强等)。而PaddleNLP内置的 :class:`MapDataset` 和 :class:`IterDataset` 正好提供了能实现以上功能的API。

所以如果您习惯使用 :class:`paddle.io.Dataset/IterableDataset` 创建数据集的话。只需要在原来的数据集上套上一层 :class:`MapDataset` 或 :class:`IterDataset` 就可以把原来的数据集对象转换成PaddleNLP的数据集。

Expand Down
1 change: 0 additions & 1 deletion docs/locale/en/LC_MESSAGES/FAQ.po
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ msgstr ""
#: ../FAQ.md:63
msgid ""
"从本地文件创建数据集时,我们 推荐 根据本地数据集的格式给出读取function并传入 load_dataset() 中创建数据集。 "
"以waybill_ie快递单信息抽取任务中的数据为例:"
msgstr ""

#: ../FAQ.md:84
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ msgid ""
"中创建数据集。"
msgstr ""

#: ../data_prepare/dataset_self_defined.rst:12
msgid ""
"以 `waybill_ie "
"<https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction/waybill_ie>`__"
" 快递单信息抽取任务中的数据为例:"
msgstr ""

#: ../data_prepare/dataset_self_defined.rst:32
msgid ""
"我们推荐将数据读取代码写成生成器(generator)的形式,这样可以更好的构建 :class:`MapDataset` 和 "
Expand Down
326 changes: 0 additions & 326 deletions examples/code_generation/codegen/README.md

This file was deleted.

0 comments on commit 307960c

Please sign in to comment.