PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.17k stars 2.94k forks source link

[Bug]: uie 使用模型推理部署报错 #5268

Open LANSEYOUYUMOWANG opened 1 year ago

LANSEYOUYUMOWANG commented 1 year ago

软件环境

- paddlepaddle:
- paddlepaddle-gpu: 2.4.0.post117
- paddlenlp: 2.5.2

重复问题

错误描述

>>> [InferBackend] Engine Created ...
-----------------------------
Traceback (most recent call last):
  File "deploy/python/infer_gpu.py", line 93, in <module>
    main()
  File "deploy/python/infer_gpu.py", line 69, in main
    outputs = predictor.predict(texts)
  File "/home/yhao/PaddleNLP-develop/model_zoo/uie/deploy/python/uie_predictor.py", line 402, in predict
    results = self._multi_stage_predict(input_data)
  File "/home/yhao/PaddleNLP-develop/model_zoo/uie/deploy/python/uie_predictor.py", line 352, in _multi_stage_predict
    result_list = self._single_stage_predict(examples)
  File "/home/yhao/PaddleNLP-develop/model_zoo/uie/deploy/python/uie_predictor.py", line 176, in _single_stage_predict
    start_prob, end_prob = self._infer(input_dict)
  File "/home/yhao/PaddleNLP-develop/model_zoo/uie/deploy/python/uie_predictor.py", line 399, in _infer
    return self.inference_backend.infer(data)
  File "/home/yhao/PaddleNLP-develop/model_zoo/uie/deploy/python/uie_predictor.py", line 73, in infer
    result = self.predictor.run(None, input_dict)
  File "/home/yhao/anaconda3/envs/paddleNlp_recompute/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 200, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid Feed Input Name:pos_ids

稳定复现步骤 & 代码

1、数据格式转换:python python doccano.py --doccano_file ./data/doccano_ext.json --splits 0.8 0.2 0 2、微调:python finetune.py --device cpu --logging_steps 10 --save_steps 100 --eval_steps 100 --seed 42 --model_name_or_path uie-base --output_dir ./checkpoint/model_best_cpu --train_path data/train.txt --dev_path data/dev.txt --max_seq_length 512 --per_device_eval_batch_size 16 --per_device_train_batch_size 16 --num_train_epochs 20 --learning_rate 1e-5 --label_names 'start_positions' 'end_positions' --do_train --do_eval --do_export --export_model_dir ./checkpoint/model_best_cpu --overwrite_output_dir --disable_tqdm True --metric_for_best_model eval_f1 --load_best_model_at_end True --save_total_limit 1 3、使用模型推理部署:python deploy/python/infer_gpu.py --model_path_prefix ${finetuned_model}/model --use_fp16 --device_id 0

linjieccc commented 1 year ago

@LANSEYOUYUMOWANG 你好,请更新deploy/python目录下的代码再尝试下 这里的变量名应该是postion_ids https://github.com/PaddlePaddle/PaddleNLP/blob/develop/model_zoo/uie/deploy/python/uie_predictor.py#L174

LANSEYOUYUMOWANG commented 1 year ago

你好,尝试更新代码后,在cpu机器上报如下错误: image