Skip to content
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

[chatglm] Add taskflow static load #6180

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

w5688414
Copy link
Contributor

@w5688414 w5688414 commented Jun 14, 2023

PR types

PR changes

Description

prefix predict

import time
from paddlenlp import Taskflow
chatbot = Taskflow("text2text_generation", batch_size=2, is_static_model=True,static_mode=True,prefix=True, dtype='float16', task_path='./inference_static')
import numpy as np
pre_caches_numpy = np.load("./prefix_tuning/pre_caches.npy")
message = "小明有15本漫画书,他每天阅读3本。请问他可以连续阅读几天?"
for i in range(10):
    start = time.perf_counter()
    output = chatbot(message,pre_caches_numpy = pre_caches_numpy)
    hf_cost = (time.perf_counter() - start) * 1000
    print("Speed Paddle:", hf_cost)
    print(len(output['result'][0]))
    print(output['result'][0])

Normal Usage

import time
from paddlenlp import Taskflow
chatbot = Taskflow("text2text_generation", batch_size=2,is_static_model=True,static_mode=True, dtype='float16', task_path='./inference_chatglm_static')
message = "强改写:一群蚂蚁士兵冲向一块披萨"
for i in range(10):
    start = time.perf_counter()
    output = chatbot(message)
    hf_cost = (time.perf_counter() - start) * 1000
    print("Speed Paddle:", hf_cost)
    print(len(output['result'][0]))
    print(output['result'][0])

静态图的目录结构,名字必须以inference开头:

inference_chatglm_static/
├── ice_text.model
├── inference.pdiparams
├── inference.pdiparams.info
├── inference.pdmodel
├── special_tokens_map.json
└── tokenizer_config.json

@paddle-bot
Copy link

paddle-bot bot commented Jun 14, 2023

Thanks for your contribution!

@w5688414 w5688414 changed the title Add taskflow static load [chatglm] Add taskflow static load Jun 14, 2023
@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Merging #6180 (fabc613) into develop (818e1a1) will decrease coverage by 0.03%.
The diff coverage is 27.77%.

@@             Coverage Diff             @@
##           develop    #6180      +/-   ##
===========================================
- Coverage    62.95%   62.93%   -0.03%     
===========================================
  Files          526      526              
  Lines        76354    76414      +60     
===========================================
+ Hits         48069    48089      +20     
- Misses       28285    28325      +40     
Impacted Files Coverage Δ
paddlenlp/taskflow/text2text_generation.py 62.50% <16.66%> (-10.50%) ⬇️
paddlenlp/taskflow/task.py 60.77% <75.00%> (-3.45%) ⬇️
paddlenlp/taskflow/taskflow.py 84.88% <100.00%> (ø)

... and 5 files with indirect coverage changes

@github-actions
Copy link

This Pull Request is stale because it has been open for 60 days with no activity. 当前Pull Request 60天内无活动,被标记为stale。

@github-actions github-actions bot added the stale label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant