diff --git a/paddlenlp/prompt/template.py b/paddlenlp/prompt/template.py index 2c6c5ef52a5c..812085269cd4 100644 --- a/paddlenlp/prompt/template.py +++ b/paddlenlp/prompt/template.py @@ -853,7 +853,7 @@ def load_from( template_config_file = os.path.join(data_path, TEMPLATE_CONFIG_FILE) if not os.path.isfile(template_config_file): raise ValueError("{} not found under {}".format(TEMPLATE_CONFIG_FILE, data_path)) - with open(template_config_file, "r") as fp: + with open(template_config_file, "r", encoding="utf-8") as fp: config = [x.strip() for x in fp] prompt = json.loads(config[0]) if len(config) > 1: diff --git a/paddlenlp/prompt/verbalizer.py b/paddlenlp/prompt/verbalizer.py index ce5d724528d6..ee5921e6b20a 100644 --- a/paddlenlp/prompt/verbalizer.py +++ b/paddlenlp/prompt/verbalizer.py @@ -215,7 +215,7 @@ def load_from(cls, data_path: os.PathLike, tokenizer: PretrainedTokenizer): verb_config_file = os.path.join(data_path, VERBALIZER_CONFIG_FILE) if not os.path.isfile(verb_config_file): raise ValueError("{} not found under {}".format(VERBALIZER_CONFIG_FILE, data_path)) - with open(verb_config_file, "r") as fp: + with open(verb_config_file, "r", encoding="utf-8") as fp: label_words = json.load(fp) verbalizer = cls(label_words, tokenizer)