-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support to read eos_id from config.json (#569)
Co-authored-by: wangzaijun <[email protected]>
- Loading branch information
1 parent
71d1208
commit 7ca5b21
Showing
2 changed files
with
34 additions
and
8 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
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,18 @@ | ||
import json | ||
import os | ||
|
||
|
||
def get_config_json(model_path: str): | ||
with open(os.path.join(model_path, "config.json"), "r") as file: | ||
json_obj = json.load(file) | ||
return json_obj | ||
|
||
|
||
def get_eos_token_ids(model_path: str): | ||
config_json = get_config_json(model_path) | ||
eos_token_id = config_json["eos_token_id"] | ||
if isinstance(eos_token_id, int): | ||
return [eos_token_id] | ||
if isinstance(eos_token_id, list): | ||
return eos_token_id | ||
assert False, "error eos_token_id format in config.json" |