DeepKE icon indicating copy to clipboard operation
DeepKE copied to clipboard

NER 任务中出现KeyError报错

Open ZZQ908268856 opened this issue 4 years ago • 19 comments

Describe the question

A clear and concise description of what the question is. NER 任务中,换成自己的标注数据集进行训练时会出现KeyError报错:KeyError: 'B-Disease'。 我已经在get_labels函数中添加了训练集中的标注标签,还是未能解决此问题,希望大佬给予帮助。

Environment (please complete the following information):

  • OS: [e.g. mac / window]
  • Python Version [e.g. 3.6] Linux python 3.8

Screenshots

If applicable, add screenshots to help explain your problem. image

Additional context

Add any other context about the problem here.

ZZQ908268856 avatar Jun 15 '22 11:06 ZZQ908268856

你好,在最开始安装依赖包的时候,如果通过pip install deepke的形式安装,修改的代码是不会生效的,得通过python setup.py install的方式才能生效

tlk1997 avatar Jun 15 '22 11:06 tlk1997

我尝试了修改完代码之后再python setup.py install,但还是报错。 此外,除了修改 get_labels 函数外,我还想问一下是否还有其他需要修改的地方? 期待您的回复,谢谢!

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月15日(星期三) 晚上7:23 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

你好,在最开始安装依赖包的时候,如果通过pip install deepke的形式安装,修改的代码是不会生效的,得通过python setup.py install的方式才能生效

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 15 '22 11:06 ZZQ908268856

有通过pip install deepke的方式安装过么,如果有的话需要讲之前装的卸载掉再重新安装

tlk1997 avatar Jun 15 '22 11:06 tlk1997

第一次pip安装过,但是可能因为网络问题安装失败,随后又转为python setup.py 安装

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月15日(星期三) 晚上7:31 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

有通过pip install deepke的方式安装过么

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 15 '22 11:06 ZZQ908268856

可以在这报错之前,print(label_list)看看

tlk1997 avatar Jun 15 '22 11:06 tlk1997

数据读取貌似没有异常,除get_lable函数之外,还有其他需要修改的么? 麻烦您啦

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月15日(星期三) 晚上7:39 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

可以在这报错之前,print(label_list)看看

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 15 '22 11:06 ZZQ908268856

其他地方就没需要改的了,你可以上传你的代码到自己仓库,我再看一看

tlk1997 avatar Jun 15 '22 11:06 tlk1997

我已将我的代码上传至我的GitHub仓库:https://github.com/ZZQ908268856/ner.git 感谢帮助

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月15日(星期三) 晚上7:50 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

其他地方就没需要改的了,你可以上传你的代码到自己仓库,我再看一看

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 15 '22 14:06 ZZQ908268856

训练数据能传一小部分上去吗

tlk1997 avatar Jun 15 '22 14:06 tlk1997

今晚网络太差,我尝试了几次都未能成功,我明天重新弄一下。

------------------ 原始邮件 ------------------ 发件人: tlk1997 @.> 发送时间: 2022年6月15日 22:28 收件人: zjunlp/DeepKE @.> 抄送: ZZQ908268856 @.>, Author @.> 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

训练数据能传一小部分上去吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 15 '22 15:06 ZZQ908268856

早上好,新的小样本训练数据代码已重新上传:https://github.com/ZZQ908268856/ner.git。路径:ner/example/ner/standard/data 劳烦查看!

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月15日(星期三) 晚上10:28 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

训练数据能传一小部分上去吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 16 '22 00:06 ZZQ908268856

好,我下午看看

tlk1997 avatar Jun 16 '22 03:06 tlk1997

我用你数据和给的代码是可以跑通的,修改后代码是不是没在运行python setup.py develop?

tlk1997 avatar Jun 16 '22 04:06 tlk1997

你是直接用我的代码和数据跑的吗?我这边按照你说的步骤试了好几次,还是会出现keyerror的错误信息:

908268856 @.***

 

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月16日(星期四) 中午12:45 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

我用你数据和给的代码是可以跑通的,修改后代码是不是没在运行python setup.py develop?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 16 '22 09:06 ZZQ908268856

是的,在linux和mac环境下都跑了没问题

tlk1997 avatar Jun 16 '22 09:06 tlk1997

我在 Linux 环境下运行步骤如下:

  1. 创建虚拟环境:python3.8 ,pytorch1.5
  2. cd 到主文件夹下分别运行:python setup.py install 和 python setup.py develop
  3. cd 到 /example/ner/standard 文件夹下,运行 python run.py 上述步骤没有问题吧?我 python run.py之后就一直报刚才那个错误了,好纳闷啊

908268856 @.***

 

------------------ 原始邮件 ------------------ 发件人: "zjunlp/DeepKE" @.>; 发送时间: 2022年6月16日(星期四) 下午5:42 @.>; @.@.>; 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

是的,在linux和mac环境下都跑了没问题

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 16 '22 09:06 ZZQ908268856

没问题,留个qq聊一下吧

tlk1997 avatar Jun 16 '22 10:06 tlk1997

908268856

------------------ 原始邮件 ------------------ 发件人: tlk1997 @.> 发送时间: 2022年6月16日 18:24 收件人: zjunlp/DeepKE @.> 抄送: ZZQ908268856 @.>, Author @.> 主题: Re: [zjunlp/DeepKE] NER 任务中出现KeyError报错 (Issue #117)

没问题,留个qq聊一下吧

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

ZZQ908268856 avatar Jun 16 '22 10:06 ZZQ908268856

在NER任务中,执行python run_bert.py 会报网络错误Connection to huggingface.co timed out('HTTPSConnectionPool(host='huggingface.co', port=443):), 请问如果换成镜像要修改那个配置吗?如果已经将bert-base-chinese模型下载本地,请问要在哪里修改配置路径吗?

liyueqing-tian avatar Jul 31 '24 02:07 liyueqing-tian