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

1

6

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
Phiz answered 26/3, 2022 at 15:3 Comment(1)
That tutorial looks kind of weird. Normally if you just want to re-use the pretrained tagger you would train an NER model without the tagger and then add it by sourcing later. Maybe take a look at the official spaCy course, which covers training an NER model in detail? course.spacy.io/enThirst
S
12

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

Safelight answered 19/4, 2022 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.