diff --git a/framework/e2e/PaddleLT_new/TestingReporter.py b/framework/e2e/PaddleLT_new/TestingReporter.py index dd9fb4781e..48eb5c3ee0 100644 --- a/framework/e2e/PaddleLT_new/TestingReporter.py +++ b/framework/e2e/PaddleLT_new/TestingReporter.py @@ -10,6 +10,7 @@ import json from pltools.res_save import xlsx_save from pltools.logger import Logger +from pltools.upload_bos import UploadBos from db.layer_db import LayerBenchmarkDB from db.info_map import precision_md5, precision_flags, performance_md5 @@ -38,6 +39,8 @@ def __init__(self, task_list=list(precision_md5.keys()), date_interval=None): self.date_interval = date_interval self.logger.get_log().info(f"self.date_interval: {self.date_interval}") + self.AGILE_PIPELINE_BUILD_ID = os.environ.get("AGILE_PIPELINE_BUILD_ID", 0) + def get_fail_case_info(self): """ 获取失败case信息 @@ -169,6 +172,14 @@ def binary_search(self, fail_dict, loop_num=1): # print("commit list is: {}".format(commit_list)) # print("commit list origin is: {}".format(commit_list_origin)) + def _bs_upload(self): + """二分结果上传bos""" + bos_path = f"PaddleLT/binary_search/build_{self.AGILE_PIPELINE_BUILD_ID}" + excel_file = "binary_search_result.xlsx" + if os.path.exists(excel_file): + UploadBos().upload_to_bos(bos_path="paddle-qa/{}".format(bos_path), file_path=excel_file) + self.logger.get_log().info("表格下载链接: https://paddle-qa.bj.bcebos.com/{}/{}".format(bos_path, excel_file)) + if __name__ == "__main__": import argparse @@ -180,13 +191,14 @@ def binary_search(self, fail_dict, loop_num=1): reporter = TestingReporter(date_interval=args.date_interval) # date_interval=2024-11-13,2024-11-14 # 打印出相对失败case信息 relative_fail_dict, absolute_fail_dict = reporter.get_fail_case_info() - print(f"relative_fail_dict:{relative_fail_dict}") + # print(f"relative_fail_dict:{relative_fail_dict}") relative_fail_num_dict = reporter.get_fail_case_num(fail_dict=relative_fail_dict) - print(f"relative_fail_num_dict:{relative_fail_num_dict}") + # print(f"relative_fail_num_dict:{relative_fail_num_dict}") absolute_fail_num_dict = reporter.get_fail_case_num(fail_dict=absolute_fail_dict) - print(f"absolute_fail_num_dict:{absolute_fail_num_dict}") + # print(f"absolute_fail_num_dict:{absolute_fail_num_dict}") # exit(0) # 打印出commit定位结果 res_dict = reporter.binary_search(fail_dict=relative_fail_dict, loop_num=args.loop_num) - print("binary search end") - print(f"res_dict:{res_dict}") + reporter._bs_upload() + # print("binary search end") + # print(f"res_dict:{res_dict}") diff --git a/framework/e2e/PaddleLT_new/db/info_map.py b/framework/e2e/PaddleLT_new/db/info_map.py index da1f62672b..adee987928 100644 --- a/framework/e2e/PaddleLT_new/db/info_map.py +++ b/framework/e2e/PaddleLT_new/db/info_map.py @@ -15,6 +15,8 @@ "paddlelt_train_api_dy2stcinn_inputspec": "76017cfeb6074f7188253df556e9fef9", "paddlelt_train_prim_inputspec": "33f3b8b4505041abe5ae221f2abd8932", "paddlelt_train_pir_infersymbolic_inputspec": "07da2ef04135d7ec5d42987705204e1f", + # "paddlelt_train_nlp_dy2stcinn_inputspec": "65e6644742b2653427cdaf51035e5ef6", + # "paddlelt_train_ocr_dy2stcinn_inputspec": "d3cd6b167556057f25568d93e0592529", } precision_flags = { @@ -75,6 +77,20 @@ "FLAGS_check_infer_symbolic": "1", "FLAGS_prim_forward_blacklist": "pd_op.dropout", }, + # "paddlelt_train_nlp_dy2stcinn_inputspec": { + # "MIN_GRAPH_SIZE": "0", + # "FLAGS_prim_all": "true", + # "FLAGS_use_cinn": "1", + # "FLAGS_prim_enable_dynamic": "true", + # "FLAGS_prim_forward_blacklist": "pd_op.dropout", + # }, + # "paddlelt_train_ocr_dy2stcinn_inputspec": { + # "MIN_GRAPH_SIZE": "0", + # "FLAGS_prim_all": "true", + # "FLAGS_use_cinn": "1", + # "FLAGS_prim_enable_dynamic": "true", + # "FLAGS_prim_forward_blacklist": "pd_op.dropout", + # }, } performance_md5 = { diff --git a/framework/e2e/PaddleLT_new/generator/builder_layer.py b/framework/e2e/PaddleLT_new/generator/builder_layer.py index d2a2347e6c..95dff660c2 100644 --- a/framework/e2e/PaddleLT_new/generator/builder_layer.py +++ b/framework/e2e/PaddleLT_new/generator/builder_layer.py @@ -19,6 +19,8 @@ elif os.environ.get("USE_PADDLE_MODEL", "None") == "PaddleNLP": import layerNLPcase import paddlenlp + + os.system("cd /root/.paddlenlp && rm -rf models") elif os.environ.get("FRAMEWORK") == "torch": import torch import layerTorchcase diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/__init__.py new file mode 100644 index 0000000000..9542c85e70 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.blenderbot." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/blenderbot_model_blenderbot_3B.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/blenderbot_model_blenderbot_3B.py new file mode 100644 index 0000000000..2f156107f9 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/blenderbot/blenderbot_model_blenderbot_3B.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BlenderbotModel, BlenderbotTokenizer + + +def LayerCase(): + """模型库中间态""" + model = BlenderbotModel.from_pretrained("blenderbot-3B") + return model + + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BlenderbotTokenizer.from_pretrained("blenderbot-3B") + inputs_dict = tokenizer( + "My friends are cool but they eat too many carbs.", return_attention_mask=True, return_token_type_ids=False + ) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BlenderbotTokenizer.from_pretrained("blenderbot-3B") + inputs_dict = tokenizer( + "My friends are cool but they eat too many carbs.", return_attention_mask=True, return_token_type_ids=False + ) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/__init__.py new file mode 100644 index 0000000000..a314316533 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.ernie." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_en.py new file mode 100644 index 0000000000..22e4934a05 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-mini-v2-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v2-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v2-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_cross_encoder.py new file mode 100644 index 0000000000..150b9cd5dc --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-v1-marco-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_para_encoder.py new file mode 100644 index 0000000000..6e21d88a68 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-v1-marco-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-para-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-para-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_query_encoder.py new file mode 100644 index 0000000000..3e694ac7b8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/ernie/ernie_model_rocketqa_v1_marco_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-v1-marco-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-query-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-v1-marco-query-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/__init__.py new file mode 100644 index 0000000000..c5bfc94969 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.fnet." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/fnet_model_fnet_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/fnet_model_fnet_large.py new file mode 100644 index 0000000000..afe76c6ba5 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/fnet/fnet_model_fnet_large.py @@ -0,0 +1,30 @@ +import paddle +import numpy as np +from paddlenlp.transformers.fnet.modeling import FNetModel +from paddlenlp.transformers.fnet.tokenizer import FNetTokenizer + +def LayerCase(): + """模型库中间态""" + model = FNetModel.from_pretrained('fnet-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = FNetTokenizer.from_pretrained('fnet-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = FNetTokenizer.from_pretrained('fnet-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/__init__.py new file mode 100644 index 0000000000..e15ed6b703 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.gpt." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_en.py new file mode 100644 index 0000000000..3e3e41ef26 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import GPTModel, GPTTokenizer + +def LayerCase(): + """模型库中间态""" + model = GPTModel.from_pretrained('gpt2-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print("inputs.shape",inputs[0].shape) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_large_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_large_en.py new file mode 100644 index 0000000000..e0a51f5bff --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_large_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import GPTModel, GPTTokenizer + +def LayerCase(): + """模型库中间态""" + model = GPTModel.from_pretrained('gpt2-large-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-large-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-large-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print("inputs.shape",inputs[0].shape) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_xl_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_xl_en.py new file mode 100644 index 0000000000..5a832f4262 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt2_xl_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import GPTModel, GPTTokenizer + +def LayerCase(): + """模型库中间态""" + model = GPTModel.from_pretrained('gpt2-xl-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-xl-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt2-xl-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_token_type_ids=False) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print("inputs.shape",inputs[0].shape) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_large_cn.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_large_cn.py new file mode 100644 index 0000000000..3588523083 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_large_cn.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import GPTModel, GPTTokenizer + +def LayerCase(): + """模型库中间态""" + model = GPTModel.from_pretrained('gpt-cpm-large-cn') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt-cpm-large-cn') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_token_type_ids=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt-cpm-large-cn') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_token_type_ids=False) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print("inputs.shape",inputs[0].shape) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_small_cn_distill.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_small_cn_distill.py new file mode 100644 index 0000000000..b429288a30 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/gpt/gpt_model_gpt_cpm_small_cn_distill.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import GPTModel, GPTTokenizer + +def LayerCase(): + """模型库中间态""" + model = GPTModel.from_pretrained('gpt-cpm-small-cn-distill') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt-cpm-small-cn-distill') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_token_type_ids=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = GPTTokenizer.from_pretrained('gpt-cpm-small-cn-distill') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_token_type_ids=False) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print("inputs.shape",inputs[0].shape) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_layoutlmv2_large_uncased.py similarity index 93% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_layoutlmv2_large_uncased.py index 5eeb853370..45e084abd7 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_layoutlmv2_large_uncased.py @@ -4,7 +4,7 @@ def LayerCase(): """模型库中间态""" - model = LayoutLMv2Model.from_pretrained('layoutlmv2-base-uncased') + model = LayoutLMv2Model.from_pretrained('layoutlmv2-large-uncased') return model def create_inputspec(): @@ -18,7 +18,7 @@ def create_inputspec(): def create_tensor_inputs(): - tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-base-uncased') + tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-large-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), @@ -30,7 +30,7 @@ def create_tensor_inputs(): def create_numpy_inputs(): - tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-base-uncased') + tokenizer = LayoutLMv2Tokenizer.from_pretrained('layoutlmv2-large-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( np.array([inputs_dict['input_ids']]), diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_vi_layoutlmv2_base_uncased.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_vi_layoutlmv2_base_uncased.py new file mode 100644 index 0000000000..51e1a78dfa --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model_vi_layoutlmv2_base_uncased.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LayoutLMv2Model, LayoutLMv2Tokenizer + +def LayerCase(): + """模型库中间态""" + model = LayoutLMv2Model.from_pretrained('vi-layoutlmv2-base-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13, 4), dtype=paddle.int64, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LayoutLMv2Tokenizer.from_pretrained('vi-layoutlmv2-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 13, 4)).astype("int64"), stop_gradient=False), + paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LayoutLMv2Tokenizer.from_pretrained('vi-layoutlmv2-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + np.random.random((1, 13, 4)).astype("int64"), + np.random.random((1, 3, 224, 224)), + np.array([inputs_dict['token_type_ids']]), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model_vi_layoutxlm_base_uncased.py similarity index 83% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model_vi_layoutxlm_base_uncased.py index 894c31cce0..68eca1c4f8 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model_vi_layoutxlm_base_uncased.py @@ -4,7 +4,7 @@ def LayerCase(): """模型库中间态""" - model = LayoutXLMModel.from_pretrained('layoutxlm-base-uncased') + model = LayoutXLMModel.from_pretrained('vi-layoutxlm-base-uncased') return model def create_inputspec(): @@ -17,7 +17,7 @@ def create_inputspec(): def create_tensor_inputs(): - tokenizer = LayoutXLMTokenizer.from_pretrained('layoutxlm-base-uncased') + tokenizer = LayoutXLMTokenizer.from_pretrained('vi-layoutxlm-base-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), @@ -28,7 +28,7 @@ def create_tensor_inputs(): def create_numpy_inputs(): - tokenizer = LayoutXLMTokenizer.from_pretrained('layoutxlm-base-uncased') + tokenizer = LayoutXLMTokenizer.from_pretrained('vi-layoutxlm-base-uncased') inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") inputs = ( np.array([inputs_dict['input_ids']]), diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/__init__.py new file mode 100644 index 0000000000..1e188a6ed3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.luke." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/luke_model_luke_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/luke_model_luke_large.py new file mode 100644 index 0000000000..1615d50b2c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/luke/luke_model_luke_large.py @@ -0,0 +1,54 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LukeModel, LukeTokenizer + +def LayerCase(): + """模型库中间态""" + model = LukeModel.from_pretrained('luke-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 9), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 9), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 9), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 1), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 1, 30), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 1), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 1), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LukeTokenizer.from_pretrained('luke-large') + inputs_dict = tokenizer("Beyoncé lives in Los Angeles.", entity_spans=[(0, 7)], add_prefix_space=True) + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + None, + paddle.to_tensor([inputs_dict['position_ids']], stop_gradient=False), + paddle.to_tensor([inputs_dict['attention_mask']], stop_gradient=False), + paddle.to_tensor([inputs_dict['entity_ids']], stop_gradient=False), + paddle.to_tensor([inputs_dict['entity_position_ids']], stop_gradient=False), + paddle.to_tensor([inputs_dict['entity_token_type_ids']], stop_gradient=False), + paddle.to_tensor([inputs_dict['entity_attention_mask']], stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LukeTokenizer.from_pretrained('luke-large') + inputs_dict = tokenizer("Beyoncé lives in Los Angeles.", entity_spans=[(0, 7)], add_prefix_space=True) + inputs_aprac = {k:paddle.to_tensor([v]) for (k, v) in inputs_dict.items()} + inputs = ( + np.array([inputs_dict['input_ids']]).astype("int64"), + None, + np.array([inputs_dict['position_ids']]).astype("int64"), + np.array([inputs_dict['attention_mask']]).astype("int64"), + np.array([inputs_dict['entity_ids']]).astype("int64"), + np.array([inputs_dict['entity_position_ids']]).astype("int64"), + np.array([inputs_dict['entity_token_type_ids']]).astype("int64"), + np.array([inputs_dict['entity_attention_mask']]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/__init__.py new file mode 100644 index 0000000000..4029c18043 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.mbart." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_many_mmt.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_many_mmt.py new file mode 100644 index 0000000000..a03a925539 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_many_mmt.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import MBartModel, MBartTokenizer + +def LayerCase(): + """模型库中间态""" + model = MBartModel.from_pretrained('mbart-large-50-many-to-many-mmt') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-many-to-many-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-many-to-many-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_one_mmt.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_one_mmt.py new file mode 100644 index 0000000000..2c8dfce19d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_many_to_one_mmt.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import MBartModel, MBartTokenizer + +def LayerCase(): + """模型库中间态""" + model = MBartModel.from_pretrained('mbart-large-50-many-to-one-mmt') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-many-to-one-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-many-to-one-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_one_to_many_mmt.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_one_to_many_mmt.py new file mode 100644 index 0000000000..8d8c4b33e4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mbart/mbart_model_mbart_large_50_one_to_many_mmt.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import MBartModel, MBartTokenizer + +def LayerCase(): + """模型库中间态""" + model = MBartModel.from_pretrained('mbart-large-50-one-to-many-mmt') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-one-to-many-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-50-one-to-many-mmt') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mpnet/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mpnet/__init__.py new file mode 100644 index 0000000000..b7e0d416ab --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mpnet/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.mpnet." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mpnet/mpnet_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mpnet/mpnet_model_mpnet_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/mpnet/mpnet_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/mpnet/mpnet_model_mpnet_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/__init__.py new file mode 100644 index 0000000000..11fc756470 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.skep." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/skep_model_skep_roberta_large_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/skep_model_skep_roberta_large_en.py new file mode 100644 index 0000000000..087ee9d3a8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/skep/skep_model_skep_roberta_large_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import SkepModel, SkepTokenizer + +def LayerCase(): + """模型库中间态""" + model = SkepModel.from_pretrained('skep_roberta_large_en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = SkepTokenizer.from_pretrained('skep_roberta_large_en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = SkepTokenizer.from_pretrained('skep_roberta_large_en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mpnet/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/__init__.py similarity index 78% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/mpnet/__init__.py rename to framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/__init__.py index 2d9fa79bab..1510c0dc62 100644 --- a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mpnet/__init__.py +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/__init__.py @@ -12,4 +12,4 @@ # 获取文件名(不含扩展名) module_name = os.path.basename(py_file)[:-3] # 导入模块 - __import__("layerNLPcase.transformers.mpnet." + module_name, globals(), locals(), []) + __import__("layerNLPcase.debug.case_bug.transformers.t5." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_11b.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_11b.py new file mode 100644 index 0000000000..a5e461a59d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_11b.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-11b') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-11b') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-11b') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_3b.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_3b.py new file mode 100644 index 0000000000..edd3458ec1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/t5/t5_model_t5_3b.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-3b') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-3b') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-3b') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/__init__.py new file mode 100644 index 0000000000..14c313343f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.unified_transformer." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/unified_transformer_model_plato_xl.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/unified_transformer_model_plato_xl.py new file mode 100644 index 0000000000..3a03f0daf0 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unified_transformer/unified_transformer_model_plato_xl.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UnifiedTransformerModel, UnifiedTransformerTokenizer + +def LayerCase(): + """模型库中间态""" + model = UnifiedTransformerModel.from_pretrained('plato-xl') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('plato-xl') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('plato-xl') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/__init__.py new file mode 100644 index 0000000000..28d62cb9e1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.unimo." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_v2.py new file mode 100644 index 0000000000..572436f0be --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-question-generation-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation-v2') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation-v2') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/__init__.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/__init__.py new file mode 100644 index 0000000000..5b467102c7 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/__init__.py @@ -0,0 +1,15 @@ +import os +import glob + +# 获取当前文件所在目录 +current_dir = os.path.dirname(__file__) + +# 获取当前目录下所有的 .py 文件路径 +py_files = glob.glob(os.path.join(current_dir, "*.py")) + +# 动态导入所有 .py 文件 +for py_file in py_files: + # 获取文件名(不含扩展名) + module_name = os.path.basename(py_file)[:-3] + # 导入模块 + __import__("layerNLPcase.debug.case_bug.transformers.xlm." + module_name, globals(), locals(), []) diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_ende_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_ende_1024.py new file mode 100644 index 0000000000..9b2587c57a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_ende_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-clm-ende-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-clm-ende-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-clm-ende-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_enfr_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_enfr_1024.py new file mode 100644 index 0000000000..93c8ceae47 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_clm_enfr_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-clm-enfr-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-clm-enfr-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-clm-enfr-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_100_1280.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_100_1280.py new file mode 100644 index 0000000000..bc6486c7bf --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_100_1280.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-100-1280') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-100-1280') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-100-1280') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_17_1280.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_17_1280.py new file mode 100644 index 0000000000..cfc085b36d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_17_1280.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-17-1280') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-17-1280') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-17-1280') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_en_2048.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_en_2048.py new file mode 100644 index 0000000000..936d5393e1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_en_2048.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-en-2048') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_ende_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_ende_1024.py new file mode 100644 index 0000000000..c2e87c2e6f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_ende_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-ende-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enfr_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enfr_1024.py new file mode 100644 index 0000000000..73e32d6d14 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enfr_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-enfr-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enro_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enro_1024.py new file mode 100644 index 0000000000..385e025f72 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/xlm/xlm_model_xlm_mlm_enro_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-enro-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-tlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_base_v1.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_base_v1.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_base_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_base_v2.py new file mode 100644 index 0000000000..0fb744398a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_base_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-base-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_base.py new file mode 100644 index 0000000000..f7a0d130ab --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_large.py new file mode 100644 index 0000000000..b457956eaa --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_small.py new file mode 100644 index 0000000000..0204e6ba35 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_tiny.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_tiny.py new file mode 100644 index 0000000000..d394d6d3db --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_tiny.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-tiny') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-tiny') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-tiny') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xlarge.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xlarge.py new file mode 100644 index 0000000000..92d3427425 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xlarge.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-xlarge') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-xlarge') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-xlarge') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xxlarge.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xxlarge.py new file mode 100644 index 0000000000..182113bac4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_chinese_xxlarge.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-chinese-xxlarge') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-xxlarge') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-chinese-xxlarge') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v1.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v1.py new file mode 100644 index 0000000000..d32d32a2b4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v1.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-large-v1') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-large-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-large-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v2.py new file mode 100644 index 0000000000..335d5b6d4e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_large_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-large-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v1.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v1.py new file mode 100644 index 0000000000..9fc246daad --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v1.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-xlarge-v1') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xlarge-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xlarge-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v2.py new file mode 100644 index 0000000000..5df066a3a5 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xlarge_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-xlarge-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xlarge-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xlarge-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v1.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v1.py new file mode 100644 index 0000000000..0843a0568e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v1.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-xxlarge-v1') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xxlarge-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xxlarge-v1') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v2.py new file mode 100644 index 0000000000..2c8f65976e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/albert/albert_model_albert_xxlarge_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import AlbertModel, AlbertTokenizer + +def LayerCase(): + """模型库中间态""" + model = AlbertModel.from_pretrained('albert-xxlarge-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xxlarge-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = AlbertTokenizer.from_pretrained('albert-xxlarge-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model_bart_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model_bart_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model_bart_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model_bart_large.py new file mode 100644 index 0000000000..09d9b0f96d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bart/bart_model_bart_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BartModel, BartTokenizer + +def LayerCase(): + """模型库中间态""" + model = BartModel.from_pretrained('bart-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BartTokenizer.from_pretrained('bart-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BartTokenizer.from_pretrained('bart-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_cased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_cased.py new file mode 100644 index 0000000000..0ec3604205 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_cased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-base-cased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_chinese.py new file mode 100644 index 0000000000..806b365f36 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-base-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_cased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_cased.py new file mode 100644 index 0000000000..b5fd685a49 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_cased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-base-multilingual-cased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_uncased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_uncased.py new file mode 100644 index 0000000000..9cd544bd65 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_multilingual_uncased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-base-multilingual-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_uncased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_uncased.py new file mode 100644 index 0000000000..fc64f0eb12 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_base_uncased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-base-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_cased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_cased.py new file mode 100644 index 0000000000..991bdb2d8f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_cased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-large-cased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-large-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-large-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_uncased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_uncased.py new file mode 100644 index 0000000000..aa5626e260 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_large_uncased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-large-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-large-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-large-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_wwm_chinese.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_wwm_chinese.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_wwm_ext_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_wwm_ext_chinese.py new file mode 100644 index 0000000000..142f063264 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_bert_wwm_ext_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('bert-wwm-ext-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-wwm-ext-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('bert-wwm-ext-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_base_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_base_chinese.py new file mode 100644 index 0000000000..b7b3fbd6e1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_base_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('macbert-base-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('macbert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('macbert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_large_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_large_chinese.py new file mode 100644 index 0000000000..00bfdd5be8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_macbert_large_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('macbert-large-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('macbert-large-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('macbert-large-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_simbert_base_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_simbert_base_chinese.py new file mode 100644 index 0000000000..017bdeeb79 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_simbert_base_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('simbert-base-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('simbert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('simbert-base-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_6l_768h.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_6l_768h.py new file mode 100644 index 0000000000..050d170748 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_6l_768h.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-6l-768h') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-6l-768h') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-6l-768h') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_base.py new file mode 100644 index 0000000000..9c278f4d4c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_medium.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_medium.py new file mode 100644 index 0000000000..b366e23357 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_medium.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-medium') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-medium') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-medium') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_mini.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_mini.py new file mode 100644 index 0000000000..8d48d8c25b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_mini.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-mini') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-mini') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-mini') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_small.py new file mode 100644 index 0000000000..04389ee4a3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_tiny.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_tiny.py new file mode 100644 index 0000000000..9f8a7b58a4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/bert/bert_model_uer_chinese_roberta_tiny.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BertModel, BertTokenizer + +def LayerCase(): + """模型库中间态""" + model = BertModel.from_pretrained('uer/chinese-roberta-tiny') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-tiny') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BertTokenizer.from_pretrained('uer/chinese-roberta-tiny') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model_blenderbot_1B_distill.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model_blenderbot_1B_distill.py new file mode 100644 index 0000000000..484aca56b6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model_blenderbot_1B_distill.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import BlenderbotModel, BlenderbotTokenizer + + +def LayerCase(): + """模型库中间态""" + model = BlenderbotModel.from_pretrained("blenderbot-1B-distill") + return model + + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = BlenderbotTokenizer.from_pretrained("blenderbot-1B-distill") + inputs_dict = tokenizer( + "My friends are cool but they eat too many carbs.", return_attention_mask=True, return_token_type_ids=False + ) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = BlenderbotTokenizer.from_pretrained("blenderbot-1B-distill") + inputs_dict = tokenizer( + "My friends are cool but they eat too many carbs.", return_attention_mask=True, return_token_type_ids=False + ) + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model_blenderbot_400M_distill.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot/blenderbot_model_blenderbot_400M_distill.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot_small/blenderbot_small_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot_small/blenderbot_small_model_blenderbot_small_90M.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot_small/blenderbot_small_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/blenderbot_small/blenderbot_small_model_blenderbot_small_90M.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_medium_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_medium_small.py new file mode 100644 index 0000000000..e48b63c26d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_medium_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ConvBertModel, ConvBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = ConvBertModel.from_pretrained('convbert-medium-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ConvBertTokenizer.from_pretrained('convbert-medium-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ConvBertTokenizer.from_pretrained('convbert-medium-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_small.py new file mode 100644 index 0000000000..1a00ae77ba --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/convbert/convbert_model_convbert_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ConvBertModel, ConvBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = ConvBertModel.from_pretrained('convbert-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ConvBertTokenizer.from_pretrained('convbert-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ConvBertTokenizer.from_pretrained('convbert-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model_ctrl.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model_ctrl.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model_sshleifer_tiny_ctrl.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model_sshleifer_tiny_ctrl.py new file mode 100644 index 0000000000..7325636484 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ctrl/ctrl_model_sshleifer_tiny_ctrl.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import CTRLModel, CTRLTokenizer + +def LayerCase(): + """模型库中间态""" + model = CTRLModel.from_pretrained('sshleifer-tiny-ctrl') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = CTRLTokenizer.from_pretrained('sshleifer-tiny-ctrl') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + None, + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + # inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = CTRLTokenizer.from_pretrained('sshleifer-tiny-ctrl') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + None, + np.array([inputs_dict['token_type_ids']]), + ) + # inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print(inputs) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model_distilbert_base_cased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model_distilbert_base_cased.py new file mode 100644 index 0000000000..599f46e0c5 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model_distilbert_base_cased.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import DistilBertModel, DistilBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = DistilBertModel.from_pretrained('distilbert-base-cased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model_distilbert_base_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/distilbert/distilbert_model_distilbert_base_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_base.py new file mode 100644 index 0000000000..93ae5eb997 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ElectraModel, ElectraTokenizer + +def LayerCase(): + """模型库中间态""" + model = ElectraModel.from_pretrained('chinese-electra-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('chinese-electra-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('chinese-electra-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_small.py new file mode 100644 index 0000000000..d378b0b158 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_chinese_electra_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ElectraModel, ElectraTokenizer + +def LayerCase(): + """模型库中间态""" + model = ElectraModel.from_pretrained('chinese-electra-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('chinese-electra-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('chinese-electra-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_base.py new file mode 100644 index 0000000000..da691e97b8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ElectraModel, ElectraTokenizer + +def LayerCase(): + """模型库中间态""" + model = ElectraModel.from_pretrained('electra-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('electra-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('electra-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_large.py new file mode 100644 index 0000000000..13b70815f3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ElectraModel, ElectraTokenizer + +def LayerCase(): + """模型库中间态""" + model = ElectraModel.from_pretrained('electra-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('electra-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('electra-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_small.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_electra_small.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_ernie_health_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_ernie_health_chinese.py new file mode 100644 index 0000000000..cba7dad175 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/electra/electra_model_ernie_health_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ElectraModel, ElectraTokenizer + +def LayerCase(): + """模型库中间态""" + model = ElectraModel.from_pretrained('ernie-health-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('ernie-health-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ElectraTokenizer.from_pretrained('ernie-health-chinese') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh.py new file mode 100644 index 0000000000..343a255388 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-1.0-base-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh_cw.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh_cw.py new file mode 100644 index 0000000000..97cd0f6bf1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_base_zh_cw.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-1.0-base-zh-cw') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-base-zh-cw') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-base-zh-cw') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_large_zh_cw.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_large_zh_cw.py new file mode 100644 index 0000000000..637fe1fc94 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_1_0_large_zh_cw.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-1.0-large-zh-cw') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-large-zh-cw') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0-large-zh-cw') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en.py new file mode 100644 index 0000000000..f2846da869 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-2.0-base-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en_finetuned_squad.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en_finetuned_squad.py new file mode 100644 index 0000000000..20745318c6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_en_finetuned_squad.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-2.0-base-en-finetuned-squad') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-en-finetuned-squad') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-en-finetuned-squad') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_zh.py new file mode 100644 index 0000000000..b7d03cae58 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_base_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-2.0-base-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_en.py new file mode 100644 index 0000000000..daa97a7dd0 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-2.0-large-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-large-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-large-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_zh.py new file mode 100644 index 0000000000..e5b740334a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_2_0_large_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-2.0-large-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-large-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-2.0-large-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_base_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_base_zh.py new file mode 100644 index 0000000000..9feac0c285 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_base_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-base-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-base-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_medium_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_medium_zh.py new file mode 100644 index 0000000000..85af200e01 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_medium_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-medium-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-medium-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-medium-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_micro_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_micro_zh.py new file mode 100644 index 0000000000..29f12f7aad --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_micro_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-micro-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-micro-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-micro-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_mini_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_mini_zh.py new file mode 100644 index 0000000000..9be8b2953f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_mini_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-mini-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-mini-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-mini-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_nano_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_nano_zh.py new file mode 100644 index 0000000000..113c7ccab3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_nano_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-nano-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-nano-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-nano-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v1_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v1_zh.py new file mode 100644 index 0000000000..3ce813bd78 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v1_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-base-v1-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-base-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-base-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v2_zh.py new file mode 100644 index 0000000000..a2f735da56 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_base_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-base-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-base-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-base-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v1_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v1_zh.py new file mode 100644 index 0000000000..a391973e9b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v1_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-medium-v1-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-medium-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-medium-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v2_zh.py new file mode 100644 index 0000000000..fc5afa9123 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_medium_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-medium-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-medium-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-medium-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v1_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v1_zh.py new file mode 100644 index 0000000000..89afeb38e5 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v1_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-micro-v1-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-micro-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-micro-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v2_zh.py new file mode 100644 index 0000000000..1cd057bdd6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_micro_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-micro-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-micro-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-micro-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v1_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v1_zh.py new file mode 100644 index 0000000000..40813d5a6e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v1_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-mini-v1-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_zh.py new file mode 100644 index 0000000000..5191fd78a3 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_mini_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-mini-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-mini-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v1_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v1_zh.py new file mode 100644 index 0000000000..5f2f4862fa --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v1_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-nano-v1-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-nano-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-nano-v1-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v2_zh.py new file mode 100644 index 0000000000..8c98f1e150 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_nano_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-nano-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-nano-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-nano-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_pico_v2_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_pico_v2_zh.py new file mode 100644 index 0000000000..1eacab6d00 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_tiny_pico_v2_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-tiny-pico-v2-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-pico-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-tiny-pico-v2-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_xbase_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_xbase_zh.py new file mode 100644 index 0000000000..8322547a4f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_3_0_xbase_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-3.0-xbase-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-xbase-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-3.0-xbase-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_base_dual_encoder_marco_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_base_dual_encoder_marco_en.py new file mode 100644 index 0000000000..751a12d020 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_base_dual_encoder_marco_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-search-base-dual-encoder-marco-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-search-base-dual-encoder-marco-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-search-base-dual-encoder-marco-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_large_cross_encoder_marco_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_large_cross_encoder_marco_en.py new file mode 100644 index 0000000000..b540d126ab --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_search_large_cross_encoder_marco_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-search-large-cross-encoder-marco-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-search-large-cross-encoder-marco-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-search-large-cross-encoder-marco-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_tiny.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_tiny.py new file mode 100644 index 0000000000..c4ec34c2ec --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_ernie_tiny.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('ernie-tiny') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-tiny') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('ernie-tiny') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_base_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_base_cross_encoder.py new file mode 100644 index 0000000000..f44f7dbd1b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_base_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-base-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-base-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-base-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_medium_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_medium_cross_encoder.py new file mode 100644 index 0000000000..78c00fc060 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_medium_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-medium-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-medium-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-medium-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_micro_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_micro_cross_encoder.py new file mode 100644 index 0000000000..44b039b40e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_micro_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-micro-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-micro-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-micro-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_mini_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_mini_cross_encoder.py new file mode 100644 index 0000000000..3c1b076eaf --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_mini_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-mini-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-mini-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-mini-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_nano_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_nano_cross_encoder.py new file mode 100644 index 0000000000..85d280d006 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_nano_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-nano-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-nano-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-nano-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_para_encoder.py new file mode 100644 index 0000000000..c979df820f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-base-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-base-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-base-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_query_encoder.py new file mode 100644 index 0000000000..3cf05883de --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_base_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-base-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-base-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-base-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_cross_encodery.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_cross_encodery.py new file mode 100644 index 0000000000..ea9df40389 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_cross_encodery.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-dureader-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-cross-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-cross-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_para_encoder.py new file mode 100644 index 0000000000..2a40543d9f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-dureader-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_query_encoder.py new file mode 100644 index 0000000000..14ec32db3c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_dureader_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-dureader-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-dureader-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_para_encoder.py new file mode 100644 index 0000000000..f2a9e32fa8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-medium-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-medium-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-medium-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_query_encoder.py new file mode 100644 index 0000000000..99c1443cda --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_medium_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-medium-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-medium-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-medium-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_para_encoder.py new file mode 100644 index 0000000000..555dff127d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-micro-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-micro-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-micro-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_query_encoder.py new file mode 100644 index 0000000000..2665c3be93 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_micro_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-micro-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-micro-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-micro-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_para_encoder.py new file mode 100644 index 0000000000..c894ee009c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-mini-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-mini-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-mini-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_query_encoder.py new file mode 100644 index 0000000000..b431a61fa6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_mini_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-mini-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-mini-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-mini-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_para_encoder.py new file mode 100644 index 0000000000..f96ec492d8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-nano-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-nano-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-nano-para-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_query_encoder.py new file mode 100644 index 0000000000..3e81efbf31 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqa_zh_nano_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqa-zh-nano-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-nano-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqa-zh-nano-query-encoder') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_cross_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_cross_encoder.py new file mode 100644 index 0000000000..5746475208 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_cross_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqav2-en-marco-cross-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-cross-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_para_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_para_encoder.py new file mode 100644 index 0000000000..73527c3424 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_para_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqav2-en-marco-para-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-para-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-para-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_query_encoder.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_query_encoder.py new file mode 100644 index 0000000000..ec5f75f16a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_rocketqav2_en_marco_query_encoder.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('rocketqav2-en-marco-query-encoder') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-query-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('rocketqav2-en-marco-query-encoder') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base.py new file mode 100644 index 0000000000..fda6a31074 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_answer_extractor.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_answer_extractor.py new file mode 100644 index 0000000000..31484b8755 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_answer_extractor.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-base-answer-extractor') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-answer-extractor') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-answer-extractor') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_en.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_en.py new file mode 100644 index 0000000000..71c35793bd --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_en.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-base-en') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-en') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_qa_filter.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_qa_filter.py new file mode 100644 index 0000000000..0f2d4aa2fe --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_base_qa_filter.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-base-qa-filter') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-qa-filter') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-base-qa-filter') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_medium.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_medium.py new file mode 100644 index 0000000000..54353e5e7a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_medium.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-medium') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_micro.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_micro.py new file mode 100644 index 0000000000..abeaa7d34b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_micro.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-micro') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_mini.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_mini.py new file mode 100644 index 0000000000..749a4e4152 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_mini.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-mini') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_nano.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_nano.py new file mode 100644 index 0000000000..00a6982152 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_nano.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-nano') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_base.py new file mode 100644 index 0000000000..fcf78d1aae --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-senta-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_medium.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_medium.py new file mode 100644 index 0000000000..33536453e6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_medium.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-senta-medium') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_micro.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_micro.py new file mode 100644 index 0000000000..9d734e077e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_micro.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-senta-micro') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_mini.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_mini.py new file mode 100644 index 0000000000..501004541a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_mini.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-senta-mini') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_nano.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_nano.py new file mode 100644 index 0000000000..9063239efc --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_uie_senta_nano.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('uie-senta-nano') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('uie-senta-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_base.py new file mode 100644 index 0000000000..d208a7cccf --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_large.py new file mode 100644 index 0000000000..90270c8b9f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_medium.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_medium.py new file mode 100644 index 0000000000..d5f04fb5b9 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_medium.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-medium') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-medium') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_micro.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_micro.py new file mode 100644 index 0000000000..3b171bab7f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_micro.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-micro') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-micro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_mini.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_mini.py new file mode 100644 index 0000000000..5e323d534d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_mini.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-mini') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-mini') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_nano.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_nano.py new file mode 100644 index 0000000000..bdd46e58f2 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_nano.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-nano') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-nano') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_pico.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_pico.py new file mode 100644 index 0000000000..704adc8980 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_pico.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-pico') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-pico') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-pico') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_xbase.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_xbase.py new file mode 100644 index 0000000000..f03a27de17 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie/ernie_model_utc_xbase.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieModel, ErnieTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieModel.from_pretrained('utc-xbase') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-xbase') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieTokenizer.from_pretrained('utc-xbase') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_ernie_ctm.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_ernie_ctm.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_nptag.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_nptag.py new file mode 100644 index 0000000000..08bb075724 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_nptag.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieCtmModel, ErnieCtmTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieCtmModel.from_pretrained('nptag') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieCtmTokenizer.from_pretrained('nptag') + inputs_dict = tokenizer("He was a puppeteer") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieCtmTokenizer.from_pretrained('nptag') + inputs_dict = tokenizer("He was a puppeteer") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_wordtag.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_wordtag.py new file mode 100644 index 0000000000..250da48519 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_ctm/ernie_ctm_model_wordtag.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieCtmModel, ErnieCtmTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieCtmModel.from_pretrained('wordtag') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieCtmTokenizer.from_pretrained('wordtag') + inputs_dict = tokenizer("He was a puppeteer") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieCtmTokenizer.from_pretrained('wordtag') + inputs_dict = tokenizer("He was a puppeteer") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model_ernie_gram_zh.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model_ernie_gram_zh.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model_ernie_gram_zh_finetuned_dureader_robust.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model_ernie_gram_zh_finetuned_dureader_robust.py new file mode 100644 index 0000000000..2831f436e5 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_gram/ernie_gram_model_ernie_gram_zh_finetuned_dureader_robust.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieGramModel, ErnieGramTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieGramModel.from_pretrained('ernie-gram-zh-finetuned-dureader-robust') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieGramTokenizer.from_pretrained('ernie-gram-zh-finetuned-dureader-robust') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieGramTokenizer.from_pretrained('ernie-gram-zh-finetuned-dureader-robust') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_ernie_m_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_ernie_m_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_ernie_m_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_ernie_m_large.py new file mode 100644 index 0000000000..ad76b52c75 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_ernie_m_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieMModel, ErnieMTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieMModel.from_pretrained('ernie-m-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('ernie-m-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('ernie-m-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_base.py new file mode 100644 index 0000000000..adcb13b2a0 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieMModel, ErnieMTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieMModel.from_pretrained('uie-m-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('uie-m-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('uie-m-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_large.py new file mode 100644 index 0000000000..ba77a36f0e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ernie_m/ernie_m_model_uie_m_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import ErnieMModel, ErnieMTokenizer + +def LayerCase(): + """模型库中间态""" + model = ErnieMModel.from_pretrained('uie-m-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('uie-m-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = ErnieMTokenizer.from_pretrained('uie-m-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/fnet/fnet_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/fnet/fnet_model_fnet_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/fnet/fnet_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/fnet/fnet_model_fnet_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/gau_alpha/gau_alpha_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/gau_alpha/gau_alpha_model_chinese_GAU_alpha_char_L_24_H_768.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/gau_alpha/gau_alpha_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/gau_alpha/gau_alpha_model_chinese_GAU_alpha_char_L_24_H_768.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/gpt/gpt_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/gpt/gpt_model_gpt2_medium_en.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/gpt/gpt_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/gpt/gpt_model_gpt2_medium_en.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model_layoutlm_base_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model_layoutlm_base_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model_layoutlm_large_uncased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model_layoutlm_large_uncased.py new file mode 100644 index 0000000000..20a4bd2eb9 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlm/layoutlm_model_layoutlm_large_uncased.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = LayoutLMModel.from_pretrained('layoutlm-large-uncased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13, 4), dtype=paddle.int64, stop_gradient=False), + # paddle.static.InputSpec(shape=(-1, 3, 224, 224), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = LayoutLMTokenizer.from_pretrained('layoutlm-large-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.to_tensor(np.random.random((1, 13, 4)).astype("int64"), stop_gradient=False), + # paddle.to_tensor(np.random.random((1, 3, 224, 224)), stop_gradient=False), + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = LayoutLMTokenizer.from_pretrained('layoutlm-large-uncased') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + np.random.random((1, 13, 4)).astype("int64"), + # np.random.random((1, 3, 224, 224)), + np.array([inputs_dict['token_type_ids']]), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model_layoutlmv2_base_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutlmv2/layoutlmv2_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutlmv2/layoutlmv2_model_layoutlmv2_base_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model_layoutxlm_base_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/debug/case_bug/transformers/layoutxlm/layoutxlm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/layoutxlm/layoutxlm_model_layoutxlm_base_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/luke/luke_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/luke/luke_model_luke_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/luke/luke_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/luke/luke_model_luke_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model_mbart_large_cc25.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model_mbart_large_cc25.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model_mbart_large_en_ro.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model_mbart_large_en_ro.py new file mode 100644 index 0000000000..93d505e60a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mbart/mbart_model_mbart_large_en_ro.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import MBartModel, MBartTokenizer + +def LayerCase(): + """模型库中间态""" + model = MBartModel.from_pretrained('mbart-large-en-ro') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-en-ro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = MBartTokenizer.from_pretrained('mbart-large-en-ro') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mobilebert/mobilebert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/mobilebert/mobilebert_model_mobilebert_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/mobilebert/mobilebert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/mobilebert/mobilebert_model_mobilebert_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_base_chinese.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_base_chinese.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_base_wwm_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_base_wwm_chinese.py new file mode 100644 index 0000000000..56e72106d6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_base_wwm_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import NeZhaModel, NeZhaTokenizer + +def LayerCase(): + """模型库中间态""" + model = NeZhaModel.from_pretrained('nezha-base-wwm-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-base-wwm-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-base-wwm-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_chinese.py new file mode 100644 index 0000000000..8aa56cbcff --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import NeZhaModel, NeZhaTokenizer + +def LayerCase(): + """模型库中间态""" + model = NeZhaModel.from_pretrained('nezha-large-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-large-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-large-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_wwm_chinese.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_wwm_chinese.py new file mode 100644 index 0000000000..47249f4146 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/nezha/nezha_model_nezha_large_wwm_chinese.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import NeZhaModel, NeZhaTokenizer + +def LayerCase(): + """模型库中间态""" + model = NeZhaModel.from_pretrained('nezha-large-wwm-chinese') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 11), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-large-wwm-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = NeZhaTokenizer.from_pretrained('nezha-large-wwm-chinese') + inputs_dict = tokenizer("欢迎使用百度飞浆!", return_tensors='pd') + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ppminilm/ppminilm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/ppminilm/ppminilm_model_ppminilm_6l_768h.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/ppminilm/ppminilm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/ppminilm/ppminilm_model_ppminilm_6l_768h.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/prophetnet/prophetnet_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/prophetnet/prophetnet_model_prophetnet_large_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/prophetnet/prophetnet_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/prophetnet/prophetnet_model_prophetnet_large_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/rembert/rembert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/rembert/rembert_model_rembert.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/rembert/rembert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/rembert/rembert_model_rembert.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt3.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt3.py new file mode 100644 index 0000000000..b869ed5a1a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt3.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RobertaModel, RobertaTokenizer + +def LayerCase(): + """模型库中间态""" + model = RobertaModel.from_pretrained('hfl/rbt3') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt3') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt3') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt4.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt4.py new file mode 100644 index 0000000000..f52bd8427b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt4.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RobertaModel, RobertaTokenizer + +def LayerCase(): + """模型库中间态""" + model = RobertaModel.from_pretrained('hfl/rbt4') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt4') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt4') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt6.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt6.py new file mode 100644 index 0000000000..233ec358e0 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbt6.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RobertaModel, RobertaTokenizer + +def LayerCase(): + """模型库中间态""" + model = RobertaModel.from_pretrained('hfl/rbt6') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt6') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbt6') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbtl3.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbtl3.py new file mode 100644 index 0000000000..2d09a0b049 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_rbtl3.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RobertaModel, RobertaTokenizer + +def LayerCase(): + """模型库中间态""" + model = RobertaModel.from_pretrained('hfl/rbtl3') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbtl3') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/rbtl3') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_roberta_wwm_ext.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_roberta_wwm_ext.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_roberta_wwm_ext_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_roberta_wwm_ext_large.py new file mode 100644 index 0000000000..acdffb54dc --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roberta/roberta_model_hfl_roberta_wwm_ext_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RobertaModel, RobertaTokenizer + +def LayerCase(): + """模型库中间态""" + model = RobertaModel.from_pretrained('hfl/roberta-wwm-ext-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/roberta-wwm-ext-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RobertaTokenizer.from_pretrained('hfl/roberta-wwm-ext-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_base.py new file mode 100644 index 0000000000..22e719e49b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_char_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_char_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_char_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_char_small.py new file mode 100644 index 0000000000..87c36daa9d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_char_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-char-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-char-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-char-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_base.py new file mode 100644 index 0000000000..6143af570a --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-sim-char-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_base.py new file mode 100644 index 0000000000..996cae30c8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_base.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-sim-char-ft-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-ft-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-ft-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_small.py new file mode 100644 index 0000000000..2fc129b60f --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_ft_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-sim-char-ft-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-ft-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-ft-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_small.py new file mode 100644 index 0000000000..b7d2b41089 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_sim_char_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-sim-char-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-sim-char-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_small.py new file mode 100644 index 0000000000..811d397c2c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_chinese_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-chinese-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-chinese-small') + inputs_dict = tokenizer("欢迎使用百度飞桨!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_discriminator.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_discriminator.py new file mode 100644 index 0000000000..6c18794f28 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_discriminator.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-english-small-discriminator') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-english-small-discriminator') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-english-small-discriminator') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_generator.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_generator.py new file mode 100644 index 0000000000..57c5c10fb4 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformer/roformer_model_roformer_english_small_generator.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerModel, RoFormerTokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerModel.from_pretrained('roformer-english-small-generator') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-english-small-generator') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors="pd") + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerTokenizer.from_pretrained('roformer-english-small-generator') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors="pd") + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_large.py new file mode 100644 index 0000000000..d0e0a43d23 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerv2Model, RoFormerv2Tokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerv2Model.from_pretrained('roformer_v2_chinese_char_large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerv2Tokenizer.from_pretrained('roformer_v2_chinese_char_large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerv2Tokenizer.from_pretrained('roformer_v2_chinese_char_large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_small.py new file mode 100644 index 0000000000..abdbfd2365 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/roformerv2/roformerv2_model_roformer_v2_chinese_char_small.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import RoFormerv2Model, RoFormerv2Tokenizer + +def LayerCase(): + """模型库中间态""" + model = RoFormerv2Model.from_pretrained('roformer_v2_chinese_char_small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = RoFormerv2Tokenizer.from_pretrained('roformer_v2_chinese_char_small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = RoFormerv2Tokenizer.from_pretrained('roformer_v2_chinese_char_small') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model_skep_ernie_1_0_large_ch.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model_skep_ernie_1_0_large_ch.py new file mode 100644 index 0000000000..81b617b46e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model_skep_ernie_1_0_large_ch.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import SkepModel, SkepTokenizer + +def LayerCase(): + """模型库中间态""" + model = SkepModel.from_pretrained('skep_ernie_1.0_large_ch') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = SkepTokenizer.from_pretrained('skep_ernie_1.0_large_ch') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = SkepTokenizer.from_pretrained('skep_ernie_1.0_large_ch') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model_skep_ernie_2_0_large_en.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/skep/skep_model_skep_ernie_2_0_large_en.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli.py new file mode 100644 index 0000000000..279292ded6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import SqueezeBertModel, SqueezeBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = SqueezeBertModel.from_pretrained('squeezebert-mnli') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = SqueezeBertTokenizer.from_pretrained('squeezebert-mnli') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + None, + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + # inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = SqueezeBertTokenizer.from_pretrained('squeezebert-mnli') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + None, + np.array([inputs_dict['token_type_ids']]), + ) + # inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print(inputs) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli_headless.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli_headless.py new file mode 100644 index 0000000000..415d67860d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_mnli_headless.py @@ -0,0 +1,41 @@ +import paddle +import numpy as np +from paddlenlp.transformers import SqueezeBertModel, SqueezeBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = SqueezeBertModel.from_pretrained('squeezebert-mnli-headless') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = SqueezeBertTokenizer.from_pretrained('squeezebert-mnli-headless') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + None, + paddle.to_tensor([inputs_dict['token_type_ids']], stop_gradient=False), + ) + # inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = SqueezeBertTokenizer.from_pretrained('squeezebert-mnli-headless') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = ( + np.array([inputs_dict['input_ids']]), + None, + np.array([inputs_dict['token_type_ids']]), + ) + # inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + print(inputs) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_uncased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/squeezebert/squeezebert_model_squeezebert_uncased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_base.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_base.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_large.py new file mode 100644 index 0000000000..84ec354fc1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_large.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_small.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_small.py new file mode 100644 index 0000000000..0a1bb08310 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_small.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-small') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-small') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_base.py new file mode 100644 index 0000000000..083f2f1873 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_base.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-v1_1-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-v1_1-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-v1_1-base') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_large.py new file mode 100644 index 0000000000..6cf62032df --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/t5/t5_model_t5_v1_1_large.py @@ -0,0 +1,40 @@ +import paddle +import numpy as np +from paddlenlp.transformers import T5Model, T5Tokenizer + +def LayerCase(): + """模型库中间态""" + model = T5Model.from_pretrained('t5-v1_1-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + None, + paddle.static.InputSpec(shape=(-1, 5), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-v1_1-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + paddle.to_tensor([inputs_dict["input_ids"]], dtype="int64", stop_gradient=False), + None, + paddle.to_tensor([decoder_inputs["input_ids"]], dtype="int64", stop_gradient=False), + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = T5Tokenizer.from_pretrained('t5-v1_1-large') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP! ") + decoder_inputs = tokenizer("It means you can") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + None, + np.array([decoder_inputs["input_ids"]]).astype("int64"), + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_v2.py new file mode 100644 index 0000000000..7f585ba90b --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import TinyBertModel, TinyBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = TinyBertModel.from_pretrained('tinybert-4l-312d-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-4l-312d-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-4l-312d-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_zh.py new file mode 100644 index 0000000000..e019ad5ff8 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_4l_312d_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import TinyBertModel, TinyBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = TinyBertModel.from_pretrained('tinybert-4l-312d-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-4l-312d-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-4l-312d-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d.py new file mode 100644 index 0000000000..92457f7c15 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import TinyBertModel, TinyBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = TinyBertModel.from_pretrained('tinybert-6l-768d') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_v2.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_v2.py new file mode 100644 index 0000000000..4dbff2622e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_v2.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import TinyBertModel, TinyBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = TinyBertModel.from_pretrained('tinybert-6l-768d-v2') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d-v2') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_zh.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_zh.py new file mode 100644 index 0000000000..88ca65eb08 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/tinybert/tinybert_model_tinybert_6l_768d_zh.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import TinyBertModel, TinyBertTokenizer + +def LayerCase(): + """模型库中间态""" + model = TinyBertModel.from_pretrained('tinybert-6l-768d-zh') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = TinyBertTokenizer.from_pretrained('tinybert-6l-768d-zh') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_plato_mini.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_plato_mini.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn.py new file mode 100644 index 0000000000..8e8ac6e864 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UnifiedTransformerModel, UnifiedTransformerTokenizer + +def LayerCase(): + """模型库中间态""" + model = UnifiedTransformerModel.from_pretrained('unified_transformer-12L-cn') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('unified_transformer-12L-cn') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('unified_transformer-12L-cn') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn_luge.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn_luge.py new file mode 100644 index 0000000000..3c708fa66d --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unified_transformer/unified_transformer_model_unified_transformer_12L_cn_luge.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UnifiedTransformerModel, UnifiedTransformerTokenizer + +def LayerCase(): + """模型库中间态""" + model = UnifiedTransformerModel.from_pretrained('unified_transformer-12L-cn-luge') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('unified_transformer-12L-cn-luge') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UnifiedTransformerTokenizer.from_pretrained('unified_transformer-12L-cn-luge') + inputs_dict = tokenizer.dialogue_encode("我爱祖国", return_tensors=True, is_split_into_words=False) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_dureader_qg.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_dureader_qg.py new file mode 100644 index 0000000000..ee405dd0a1 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_dureader_qg.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-dureader_qg') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-dureader_qg') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-dureader_qg') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_large.py new file mode 100644 index 0000000000..4be04691f7 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_large.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-large') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-large') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-large') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_lcsts_new.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_lcsts_new.py new file mode 100644 index 0000000000..3b0261d429 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_lcsts_new.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-lcsts-new') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-lcsts-new') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-lcsts-new') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation.py new file mode 100644 index 0000000000..b093f7d67e --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-question-generation') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_dureader_qg.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_dureader_qg.py new file mode 100644 index 0000000000..c8f21eb1a2 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_question_generation_dureader_qg.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-question-generation-dureader_qg') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation-dureader_qg') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-question-generation-dureader_qg') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_summary.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_summary.py new file mode 100644 index 0000000000..a8b6b8fc95 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/unimo/unimo_model_unimo_text_1_0_summary.py @@ -0,0 +1,29 @@ +import paddle +import numpy as np +from paddlenlp.transformers import UNIMOModel, UNIMOTokenizer + +def LayerCase(): + """模型库中间态""" + model = UNIMOModel.from_pretrained('unimo-text-1.0-summary') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 15), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-summary') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(paddle.to_tensor(v, stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = UNIMOTokenizer.from_pretrained('unimo-text-1.0-summary') + inputs_dict = tokenizer.gen_encode("Welcome to use PaddlePaddle and PaddleNLP!", return_tensors=True) + inputs = tuple(np.array(v) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model_xlm_mlm_tlm_xnli15_1024.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model_xlm_mlm_tlm_xnli15_1024.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model_xlm_mlm_xnli15_1024.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model_xlm_mlm_xnli15_1024.py new file mode 100644 index 0000000000..83b93b10dd --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlm/xlm_model_xlm_mlm_xnli15_1024.py @@ -0,0 +1,35 @@ +import paddle +import numpy as np +from paddlenlp.transformers import XLMModel, XLMTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLMModel.from_pretrained('xlm-mlm-xnli15-1024') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 16), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + paddle.to_tensor([inputs_dict['input_ids']], stop_gradient=False), + paddle.ones_like(inputs_dict['input_ids']) * tokenizer.lang2id["en"], + ) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLMTokenizer.from_pretrained('xlm-mlm-xnli15-1024') + inputs_dict = tokenizer("Welcome to use PaddlePaddle and PaddleNLP!", lang="en") + inputs = ( + np.array([inputs_dict["input_ids"]]).astype("int64"), + np.ones((1, 16)).astype("int64") * 4, + ) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_base.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_base.py new file mode 100644 index 0000000000..8bdd8e7938 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_base.py @@ -0,0 +1,30 @@ +import paddle +import numpy as np +from paddlenlp.transformers.xlnet.modeling import XLNetModel +from paddlenlp.transformers.xlnet.tokenizer import XLNetTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLNetModel.from_pretrained('chinese-xlnet-base') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-base') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_large.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_large.py new file mode 100644 index 0000000000..6e8a71b1c6 --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_large.py @@ -0,0 +1,31 @@ +import paddle +import numpy as np +from paddlenlp.transformers.xlnet.modeling import XLNetModel +from paddlenlp.transformers.xlnet.tokenizer import XLNetTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLNetModel.from_pretrained('chinese-xlnet-large') + return model + + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-large') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_mid.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_mid.py new file mode 100644 index 0000000000..5d2a3f52ca --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_chinese_xlnet_mid.py @@ -0,0 +1,30 @@ +import paddle +import numpy as np +from paddlenlp.transformers.xlnet.modeling import XLNetModel +from paddlenlp.transformers.xlnet.tokenizer import XLNetTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLNetModel.from_pretrained('chinese-xlnet-mid') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-mid') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('chinese-xlnet-mid') + inputs_dict = tokenizer("欢迎使用百度飞桨!") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_xlnet_base_cased.py similarity index 100% rename from framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model.py rename to framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_xlnet_base_cased.py diff --git a/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_xlnet_large_cased.py b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_xlnet_large_cased.py new file mode 100644 index 0000000000..5d832dbc0c --- /dev/null +++ b/framework/e2e/PaddleLT_new/layerNLPcase/transformers/xlnet/xlnet_model_xlnet_large_cased.py @@ -0,0 +1,30 @@ +import paddle +import numpy as np +from paddlenlp.transformers.xlnet.modeling import XLNetModel +from paddlenlp.transformers.xlnet.tokenizer import XLNetTokenizer + +def LayerCase(): + """模型库中间态""" + model = XLNetModel.from_pretrained('xlnet-large-cased') + return model + +def create_inputspec(): + inputspec = ( + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + paddle.static.InputSpec(shape=(-1, 13), dtype=paddle.float32, stop_gradient=False), + ) + return inputspec + + +def create_tensor_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('xlnet-large-cased') + inputs_dict = tokenizer("Hey, Paddle-paddle is awesome !") + inputs = tuple(paddle.to_tensor([v], stop_gradient=False) for (k, v) in inputs_dict.items()) + return inputs + + +def create_numpy_inputs(): + tokenizer = XLNetTokenizer.from_pretrained('xlnet-large-cased') + inputs_dict = tokenizer("Hey, Paddle-paddle is awesome !") + inputs = tuple(np.array([v]) for (k, v) in inputs_dict.items()) + return inputs diff --git a/framework/e2e/PaddleLT_new/start.sh b/framework/e2e/PaddleLT_new/start.sh index fb60065dd4..27ec3e135c 100755 --- a/framework/e2e/PaddleLT_new/start.sh +++ b/framework/e2e/PaddleLT_new/start.sh @@ -8,9 +8,12 @@ source ./set_docker_env.sh # 设定docker环境相关参数 export docker_name=${DOCKER_NAME:-PaddleLayerTest_${AGILE_PIPELINE_BUILD_NUMBER}} docker container ls -a --filter "name=${docker_name}" --format "{{.ID}}" | xargs -r docker rm -f +mkdir root_tmp + nvidia-docker run --rm -i --name ${docker_name} --privileged --shm-size=128g --net=host \ -w /workspace \ -v $PWD:/workspace \ + -v root_tmp:/root \ -e "AK=${AK}" -e "SK=${SK}" \ -e "http_proxy=${http_proxy}" \ -e "https_proxy=${https_proxy}" \