Skip to content

Commit

Permalink
fix export and infer model of gpt. (PaddlePaddle#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHUI committed Sep 14, 2021
1 parent 71aff69 commit 45967dc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 1 addition & 3 deletions examples/language_model/gpt/deploy/python/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ def main():
"问题:中国的首都是哪里?答案:",
"问题:世界上最高的山峰是? 答案:",
]
end_id = tokenizer.eol_token_id

dataset = [[
np.array(tokenizer(text)["input_ids"]).astype("int64").reshape([1, -1]),
np.array(end_id).astype("int32").reshape([1])
np.array(tokenizer(text)["input_ids"]).astype("int64").reshape([1, -1])
] for text in ds]
outs = predictor.predict(dataset)
for res in outs:
Expand Down
2 changes: 0 additions & 2 deletions examples/language_model/gpt/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def main():
input_spec=[
paddle.static.InputSpec(
shape=[None, None], dtype="int64"), # input_ids
paddle.static.InputSpec(
shape=[1], dtype="int32"), # end_id
])

# Save converted static graph model
Expand Down

0 comments on commit 45967dc

Please sign in to comment.