Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • ERNIE
  • Issue
  • #392

E
ERNIE
  • 项目概览

PaddlePaddle / ERNIE
大约 2 年 前同步成功

通知 115
Star 5997
Fork 1271
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 29
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 0
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
E
ERNIE
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 29
    • Issue 29
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 0
    • 合并请求 0
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 1月 03, 2020 by saxon_zh@saxon_zhGuest

Missing use_task_id in pre-trained ERNIE-en-base

Created by: winston-zillow

Download https://ernie.bj.bcebos.com/ERNIE_Base_en_stable-2.0.0.tar.gz, uncompress and the ernie_config.json does not have a value for use_task_id.

{
  "attention_probs_dropout_prob": 0.1, 
  "hidden_act": "gelu", 
  "hidden_dropout_prob": 0.1, 
  "hidden_size": 768, 
  "initializer_range": 0.02, 
  "max_position_embeddings": 512, 
  "num_attention_heads": 12, 
  "num_hidden_layers": 12, 
  "sent_type_vocab_size": 4, 
  "task_type_vocab_size": 16, 
  "vocab_size": 30522
}

As a consequence, when attempting to save the model using save_inference_model (so that I can convert it to ONNX using the paddle2onnx tool), it would complain the task id input is missing after pruning the model for inference inside save_inference_model as shown in my debug outputs by modifying the save method locally:

cloned 2 -> read_file_0.tmp_0 VarType.LOD_TENSOR False
cloned 6 -> _input_reader_reader VarType.READER True
cloned 32 -> read_file_0.tmp_6 VarType.LOD_TENSOR False
cloned 41 -> read_file_0.tmp_5 VarType.LOD_TENSOR False
cloned 44 -> read_file_0.tmp_4 VarType.LOD_TENSOR False
cloned 63 -> read_file_0.tmp_1 VarType.LOD_TENSOR False
cloned 219 -> read_file_0.tmp_3 VarType.LOD_TENSOR False
cloned 374 -> read_file_0.tmp_2 VarType.LOD_TENSOR False
pruned 116 -> read_file_0.tmp_4 VarType.LOD_TENSOR False
pruned 117 -> read_file_0.tmp_0 VarType.LOD_TENSOR False
pruned 129 -> read_file_0.tmp_1 VarType.LOD_TENSOR False
pruned 718 -> read_file_0.tmp_2 VarType.LOD_TENSOR False

For your reference, my model saving codes look like

# cloned and modified from `ernie/finetune/classifier`
def create_model(args,
                 pyreader_name,
                 ernie_config,
                 is_prediction=False,
                 task_name="",
                 is_classify=False,
                 is_regression=False,
                 ernie_version="1.0"):
     ...
    (src_ids, sent_ids, pos_ids, task_ids, input_mask, labels,
     qids) = fluid.layers.read_file(pyreader)

    ernie = ErnieModel(
    ...
    cls_feats = ernie.get_pooled_output()
    inputs = (src_ids, sent_ids, pos_ids, task_ids, input_mask)
    return inputs, cls_feats, pyreader, (labels, qids)

# imitating `run_classifier.py`
startup_prog = fluid.Program()
train_program = fluid.Program()

with fluid.program_guard(train_program, startup_prog):
    with fluid.unique_name.guard():
        inputs, ernie_latent, train_pyreader, _ = create_model(
            args,
            pyreader_name='input_reader',
            ernie_config=ernie_config,
            is_classify=args.is_classify,
            is_regression=args.is_regression)

        # exe.run(startup_prog) . # i think there is no need to run this
        init_pretraining_params(
            exe,
            args.init_pretraining_params,
            main_program=startup_prog,
            use_fp16=args.use_fp16)
    fluid.io.save_inference_model(dirname="/ernie_onnx_path",
                                 feeded_var_names=[var.name for var in inputs],
                                 target_vars=[ernie_latent],
                                 main_program=train_program,
                                 executor=exe)

After I set use_task_id to true in the config file, saving the inference model will work. Please confirm if that's the right fix (and fix the pre-trained archive.)

指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/ERNIE#392
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7