ValueError:[E143]组件“标记器”的标签未初始化

Dia*_*na 6 named-entity-recognition spacy-3

我一直在按照本教程创建自定义 NER。但是,我不断收到此错误: ValueError: [E143] Labels for component 'tagger' not initialized. This can be fixed by calling add_label, or by providing a representative batch of examples to the component's 初始化 method.

这就是我定义 spacy 模型的方式:

import spacy
from spacy.tokens import DocBin
from tqdm import tqdm

nlp = spacy.blank("ro") # load a new spacy model
source_nlp = spacy.load("ro_core_news_lg")
nlp.tokenizer.from_bytes(source_nlp.tokenizer.to_bytes())
nlp.add_pipe("tagger", source=source_nlp)

doc_bin = DocBin() # create a DocBin object
Run Code Online (Sandbox Code Playgroud)

小智 12

我刚刚遇到同样的问题。设置配置文件的图片会误导您。如果您只想运行 tutrital,您可以像这样设置配置文件。 只需单击 ner 上的复选框