Skip to content

【PaddleNLP No.20】Create ernie-3.0 deploy with paddle.inference & add training without hf #10475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

hanlintang
Copy link
Contributor

PR types

Function optimization

PR changes

Models

Description

  1. 将目录中的slm/model_zoo/ernie-3.0/infer.py加入文档,并进行PIR适配;
  2. 为NER训练提供网络无法连接到HF的替代脚本slm/model_zoo/ernie-3.0/run_token_cls_without_hf.py;
  3. 修改文档slm/model_zoo/ernie-3.0/README.md;
  4. 针对FastDeploy与paddle 3.0.0不适配的情况,重新实现基于paddle.inference的推理脚本,包括文本分类与NER两个任务;
  • 文本分类:slm/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py
  • NER:slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py
  1. 针对推理示例变化更新部署文档slm/model_zoo/ernie-3.0/deploy/python/README.md

Issue: #9763
@DrownFish19

Copy link

paddle-bot bot commented Apr 23, 2025

Thanks for your contribution!

@DrownFish19 DrownFish19 added the HappyOpenSource 快乐开源活动issue与PR label Apr 24, 2025
@DrownFish19 DrownFish19 requested a review from Copilot April 24, 2025 01:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a Paddle Inference–based deploy for the Ernie‑3.0 model and introduces an alternative training script for NER when Hugging Face connectivity is unavailable.

  • Adds a new script (run_token_cls_without_hf.py) for NER training without HF.
  • Updates inference scripts (infer.py, token_cls_infer.py, seq_cls_infer.py) to leverage paddle.inference with new model file suffixes.
  • Revises documentation in README files to reflect deployment changes.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
slm/model_zoo/ernie-3.0/run_token_cls_without_hf.py Adds an alternative training script for NER.
slm/model_zoo/ernie-3.0/infer.py Updates inference file paths to use new suffixes.
slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py Replaces fastdeploy with paddle.inference and adjusts preprocessing/postprocessing.
slm/model_zoo/ernie-3.0/deploy/python/seq_cls_infer.py Updates prediction logic and removes fastdeploy dependencies.
slm/model_zoo/ernie-3.0/deploy/python/README.md Revises usage examples to reflect updated inference arguments.
slm/model_zoo/ernie-3.0/README.md Adds deploy instructions for infer.py and run_token_cls_without_hf.py.
Comments suppressed due to low confidence (2)

slm/model_zoo/ernie-3.0/infer.py:190

  • Ensure that args.model_path includes a trailing path separator or consider using os.path.join to construct the complete model file path, so that the concatenated file name is formed correctly.
model_file=args.model_path + f"model{PADDLE_INFERENCE_MODEL_SUFFIX}"

slm/model_zoo/ernie-3.0/deploy/python/token_cls_infer.py:100

  • Verify that converting infer_data to a numpy array returns the expected shape; if the inference API now wraps the results differently compared to previous versions, you may need to adjust the postprocessing accordingly.
result = np.array(infer_data)

Copy link
Collaborator

@DrownFish19 DrownFish19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.92%. Comparing base (ce7b4cc) to head (b96de4b).
Report is 45 commits behind head on develop.

❌ Your project status has failed because the head coverage (48.92%) is below the target coverage (58.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10475      +/-   ##
===========================================
- Coverage    48.99%   48.92%   -0.07%     
===========================================
  Files          765      767       +2     
  Lines       125974   126238     +264     
===========================================
+ Hits         61720    61766      +46     
- Misses       64254    64472     +218     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@luotao1 luotao1 merged commit 1f9b47e into PaddlePaddle:develop May 7, 2025
10 of 13 checks passed
@hanlintang hanlintang deleted the ernie3 branch May 7, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants