Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[RFC]: templates for paddlenlp #3346

wj-Mcat started this conversation in Ideas
Sep 22, 2022 · 1 comments · 1 reply
Discussion options

背景

目前框架中已经添加了一些新特性,比如PretrainedConfig、更多中间输入输出(output_attentionoutput_hidden_statesreturn_dict)以及单测等模块,此时如果要开发一个新模型就需要遵循各自模块的规范将以上特性添加到新模型当中。需要注意很多细节,此时需要有一个template模块来初始化:模型、单测甚至是example的代码。

灵感

还是来自于HuggingFace/Transformer中的template模块,其配置了常规的代码模板,比如:add_new_model,add_new_example等,开发者只需要根据关键信息配置即可实现新模型的初始化。

此模板可以生成XXXModelXXXForYYY类型的模型,并直接配备有最新特性,故此方法比较适合于制定最新规范。

解决方案

要使用template来自动生成对应模板代码,需要以下功能:

  • 模板引擎,支持关键字配置,处理逻辑流,可使用jinja2作为模板引擎
  • 命令行工具,可通过类似于paddlenlp new model来实现新模型的自动化生成。
    • 也可以添加一些scripts来支持此特性

在以上两点中,模板引擎是比较容易实现,可是命令行工具(参照transformer-cli)属于新特性,是否需要实现?实现哪些功能?实现能带来哪些功能上的体验?

如果目前不想实现paddlenlp-cli也可直接将对应的脚本放置在templates目录下来运行,最简单方便。

命令行工具

灵感还是来自于huggingface/transformer, allennlp等,都有自己的工具来实现一些自动化的操作。

是否需要实现

我个人觉得命令行工具能够提升框架的使用体验,因为这个能提供一些实用的功能给new babies、Developers以及Contributors。

实现哪些功能

可实现的功能就可以有很多:

  • paddlenlp search
  • paddlenlp download --cache_dir
  • paddlenlp convert --pytorch-weight
  • paddlenlp add-new-model
  • paddlenlp add-new-example
  • paddlenlp init
    • text-classification
    • text-to-image
    • text-generation
    • few-shot
    • ...
  • paddlenlp train ...

paddlenlp init 是用来初始化某一个具体任务下的模型,比如我想新创建一个文本分类的任务,我只需要需要使用paddlenlp init text-classification就可以生成基于paddlenlp的不同模型、不同数据集的代码。

总结

  • templates这个比较简单,适合做模型的规范,也可以减少其他同学的在新模型复现和调整过程中的工作量,感觉可以添加。
  • paddlenlp cli工具可做的东西太多了,可是有没有必要做,怎么做,什么时候做都是需要讨论的。
You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

感觉paddlenlp download --cache_dir这个得做,咱们这下载权重不能像huggingface.co在网页上直接下载权重。

You must be logged in to vote
1 reply
Comment options

wj-Mcat Sep 22, 2022
Collaborator Author

这个我觉得有必要做,其实我更想做的其实是: paddle init text-classification这个东西,能够直接给给你生成对应任务的代码,甚至这部分也是可以开放给开发者自行贡献给其他开发者用,逐渐扩大生态圈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /