python-3.x - 使用 Spacy 训练 NER 从简历中提取技能。过渡中的 U-entity_name 是什么意思
问题描述
我正在使用训练 spacy NER 从简历中提取技能信息。但错误是
在 NER 模型中找不到名为“U-SKILL”的转换
训练数据:
[(u"我有 2 年的 Python 经验", {"entities": [(30, 35, "SKILL")]})]
代码 :
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"]
with nlp.disable_pipes(*other_pipes):
optimizer = nlp.begin_training()
for i in range(10):
random.shuffle(train_data)
for text, annotations in train_data:
nlp.update([text], [annotations], sgd=optimizer)```
Error Traceback:
```Traceback (most recent call last):
File "<ipython-input-1-b5f869eaaf43>", line 1, in <module>
runfile('/home/abhishek/Desktop/Monster/Resume_Parser/MI_Resume/skills_ner.py', wdir='/home/abhishek/Desktop/Monster/Resume_Parser/MI_Resume')
File "/usr/lib/python3/dist-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/abhishek/Desktop/Monster/Resume_Parser/MI_Resume/skills_ner.py", line 234, in <module>
nlp.update([text], [annotations], sgd=optimizer)
File "/home/abhishek/.local/lib/python3.6/site-packages/spacy/language.py", line 452, in update
proc.update(docs, golds, sgd=get_grads, losses=losses, **kwargs)
File "nn_parser.pyx", line 413, in spacy.syntax.nn_parser.Parser.update
File "nn_parser.pyx", line 516, in spacy.syntax.nn_parser.Parser._init_gold_batch
File "ner.pyx", line 106, in spacy.syntax.ner.BiluoPushDown.preprocess_gold
File "ner.pyx", line 165, in spacy.syntax.ner.BiluoPushDown.lookup_transition
KeyError: "[E022] Could not find a transition with the name 'U-SKILL' in the NER model."```
解决方案
我最近在训练自己的自定义 NER 模型时遇到了同样的错误消息。由于您没有显示整个代码段,因此我不确定它是否是由同一问题引起的。就我而言,我在实体识别器中引入的新标签都是小写的,这实际上是一个非常愚蠢的错误。
for label in entity_types:
ner.add_label(label.upper())
一旦我使用str.upper()
.
您可能还应该参考https://spacy.io/usage/training#ner以及添加新实体类型的示例。
推荐阅读
- bash - 如何制作本地 .command 终端脚本?
- java - 无法解析符号“抵押”
- linkedin - 从 Integromat 自动发布到 Linked:无法分享图片帖子
- java - 有没有办法让浮动操作按钮根据导航主机中当前的片段来执行某些操作?
- php - 如何将 H1 仅保留在主页上?
- java - 枚举中的字段和方法危险级别
- c# - 当语言设置为法语时,小数点分隔符“,”在绑定到双属性时将被忽略
- asp.net-core - 发布后 ASP.NET Core Web API 不运行,上传到主机后出现 500.30 错误
- python - Pandas Dataframe 中包含字符串列表作为值的列中的项目的值计数
- html - 链接:响应头 VS HTML