I cannot initialise EntityRecognizer object with no examples, like in the docs
How to reproduce the behaviour
cfg = {"model": DEFAULT_NER_MODEL}
model = registry.resolve(cfg, validate=True)["model"]
ner = EntityRecognizer(nlp.vocab, model)
ner.initialize(lambda: [], nlp=nlp)
The error I get:
TypeError: [E930] Received invalid get_examples callback in `Parser.initialize`. Expected function that returns an iterable of Example objects but got: []
In the docs, there is an example with a lambda function returning an empty list: https://spacy.io/api/entityrecognizer#initialize.
Your Environment
- spaCy version: 3.2.1
- Platform: Linux-5.10.0-1057-oem-x86_64-with-glibc2.31
- Python version: 3.9.0
- Pipelines: en_core_web_sm (3.2.0), en_core_web_trf (3.2.0)
Thanks for the note! This looks like an error in the API docs for a number of the pipeline components. Many of them do require at least one example in order to initialize the internal models correctly. We'll get this updated!
What are you trying to accomplish with this code, though? This kind of initialization is useful for a unit test but not really for typical use in a pipeline. Usually you'd use spacy train with a config (strongly recommended), or you'd call nlp.initialize with representative training examples for the whole pipeline instead.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.