-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed tokenizer in glm blankfilling (#13)
* fixed tokenizer in glm blankfilling Signed-off-by: Anhforth <yanzhaodong2021@163.com> * Update glm_generate_samples_en.py Co-authored-by: Anhforth <yanzhaodong2021@163.com> Co-authored-by: Zac Liu <liuguang@baai.ac.cn>
- Loading branch information
1 parent
1a4e253
commit 97ffea4
Showing
4 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright © 2022 BAAI. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License") | ||
|
||
import torch | ||
from flagai.model.predictor.predictor import Predictor | ||
from flagai.auto_model.auto_loader import AutoLoader | ||
if __name__ == "__main__": | ||
"""Main training program.""" | ||
print('Generate Samples') | ||
# Random seeds for reproducability. | ||
# Model, | ||
loader = AutoLoader(task_name='lm', | ||
model_name='GLM-large-en', | ||
only_download_config=False) | ||
model = loader.get_model() | ||
tokenizer = loader.get_tokenizer() | ||
model.cuda(torch.cuda.current_device()) | ||
|
||
predictor = Predictor(model, tokenizer) | ||
# generate samples | ||
text = [ | ||
'Question: Is drinking beer bad for your health? Answer: [gMASK]', | ||
] | ||
for t in text: | ||
output = predictor.predict_generate_randomsample( | ||
t, top_k=50, repetition_penalty=4.0, top_p=1.0) | ||
print(t, '\n', output) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters