ConfigValidationError sklearn-cat #11622
-
I got the following error when loading a nlp that has been trained and exported out to disk.
And here is how I train the model (it works fine right after I train it, the issue is reloading the nlp model after exporting it)
Suppose I add that config line, I will experience the following error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @yw2903 , There are two ways you can solve this:
@Language.factory("sklearn-cat")
def my_component(doc, sklearn_model: str, label: str, classes: List[str])):
# do something
return doc This might work as a toy example but it's not the best practice (harder to extend, you have something happening in the global namespace, etc.). Ideally you want everything to happen inside a single class, it's more extensible that way. And so, another approach would be to...
|
Beta Was this translation helpful? Give feedback.
Hi @yw2903 ,
There are two ways you can solve this:
Language.factory
instead ofLanguage.component
, then include the extra settings in themy_component
function (c.f. https://spacy.io/usage/processing-pipelines#custom-components-factories). Something like this:This might work as a toy example but it's not the best practice (harder to extend, you have something happening in the global namespace, etc.). Ideally you want everything to happen inside a single class, it's more extensible that way. And so, another a…