'Error during training entity linker model with cutom spacy ner model
I have already trained an Entity Linker (EL) model with spacy's en_core_web_sm
model without any problems. But when I train a EL model with a custom NER Model, I get an error message. How can I solve the problem? Adding 'sentencizer' component to pipeline doesn't solve the problem.
Error:
AttributeError: 'NoneType' object has no attribute 'as_doc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("__main__"))
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\Spacy_NEL_Models\en_el_ambigue\en_el_ambigue\en_el_ambigue.py", line 123, in <module>
nlp.update(texts, annotations, drop=0.2, losses = losses, sgd=optimizer,)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\language.py", line 519, in update
proc.update(docs, golds, sgd=get_grads, losses=losses, **kwargs)
File "pipes.pyx", line 1237, in spacy.pipeline.pipes.EntityLinker.update
RuntimeError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipeline with: nlp.add_pipe(nlp.create_pipe('sentencizer')) Alternatively, add the dependency parser, or set sentence boundaries by setting doc[i].is_sent_start.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|