Search code examples
named-entity-recognitionspacy-3

ValueError: [E143] Labels for component 'tagger' not initialized


I've been following this tutorial to create a custom NER. However, I keep getting this error: 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 initialize method.

This is how I defined the spacy model:

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

Solution

  • I just meet the same problem. The picture of setting the config file is misleading you. If you just want to run through the tutrital, you can set the config file like this. only click the check box on ner