taishan1994 / BERT-BILSTM-CRF

使用BERT-BILSTM-CRF进行中文命名实体识别。
312 stars 38 forks source link

预测问题报错 #28

Open kejiakebujia opened 5 months ago

kejiakebujia commented 5 months ago

Traceback (most recent call last): File "E:\自然语言处理\BERT-BILSTM-CRF-main\predict.py", line 70, in predictor = Predictor(data_name) File "E:\自然语言处理\BERT-BILSTM-CRF-main\predict.py", line 24, in init self.ner_args = get_args(os.path.join("./checkpoint/{}/".format(data_name), "ner_args.json"), "ner_args") File "E:\自然语言处理\BERT-BILSTM-CRF-main\predict.py", line 15, in get_args args_dict = json.load(fp) File "E:\Anaconda\lib\json__init__.py", line 293, in load return loads(fp.read(), File "E:\Anaconda\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 180: invalid start byte

taishan1994 commented 5 months ago

确认是否有args.json

kejiakebujia commented 5 months ago

确认是否有args.json

好像是没有的,请问作者这个文件从哪获取放置在哪个文件夹下

taishan1994 commented 5 months ago

先训练,保存模型后会生成

kejiakebujia commented 5 months ago

先训练,保存模型后会生成 我已经按照你的代码训练过了,想问下接下来怎么保存模型操作。抱歉我是小白很生疏

kejiakebujia commented 5 months ago

先训练,保存模型后会生成

你好,但是我看有一个ner_args.json文件

kejiakebujia commented 5 months ago

确认是否有args.json

解决了 在main函数下添加 with open(os.path.join(args.output_dir, "args.json"), "w", encoding="utf-8") as fp: json.dump(vars(args), fp, ensure_ascii=False, indent=2)