Can't find factory for 'relation_extractor' for language English (en) #12958
-
Hi Team, am not able to load the model, showing factory for 'relation_extractor' for language English (en) issue. import spacy ValueError Traceback (most recent call last) File ~\AppData\Local\anaconda3\lib\site-packages\spacy_init_.py:51, in load(name, vocab, disable, enable, exclude, config) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\util.py:467, in load_model(name, vocab, disable, enable, exclude, config) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\util.py:539, in load_model_from_path(model_path, meta, vocab, disable, enable, exclude, config) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\util.py:587, in load_model_from_config(config, meta, vocab, disable, enable, exclude, auto_fill, validate) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\language.py:1847, in Language.from_config(cls, config, vocab, disable, enable, exclude, meta, auto_fill, validate) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\language.py:814, in Language.add_pipe(self, factory_name, name, before, after, first, last, source, config, raw_config, validate) File ~\AppData\Local\anaconda3\lib\site-packages\spacy\language.py:683, in Language.create_pipe(self, factory_name, name, config, raw_config, validate) ValueError: [E002] Can't find factory for 'relation_extractor' for language English (en). This usually happens when spaCy calls Available factories: attribute_ruler, tok2vec, merge_noun_chunks, merge_entities, merge_subtokens, token_splitter, doc_cleaner, parser, beam_parser, lemmatizer, trainable_lemmatizer, entity_linker, entity_ruler, tagger, morphologizer, ner, beam_ner, senter, sentencizer, spancat, spancat_singlelabel, span_finder, future_entity_ruler, span_ruler, textcat, textcat_multilabel, en.lemmatizer Your Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! The @Language.factory(
"relation_extractor",
...
)
def make_relation_extractor(
nlp: Language, name: str, model: Model, *, threshold: float
):
... You can do so by importing the relevant function at run-time, by using entry-points and/or packaging the model as explained here and here. The final part of the error message makes this explicit: spaCy's internal configuration & catalogue system searches for the "relation_extractor" factory but can't find it because it's defined in code that it hasn't seen at the time when you're running this I know this can all be a bit daunting if you haven't worked with the config system much before. A good introduction is this video by Ines: https://www.youtube.com/watch?v=BWhh3r6W-qE Hope this helps! |
Beta Was this translation helpful? Give feedback.
Hi!
The
relation_extractor
is not a built-in functionality in spaCy. Assuming you're using a custom implementation inspired by e.g. this REL tutorial, then you have to make sure that this definition is exposed to your working environment:You can do so by importing the relevant function at run-time, by using entry-points and/or packaging the model as explained here and here.
The final part of the error message makes this explicit: spaCy's internal configuration & catalogue system searches for the "relation_extractor" factory but can't …