SpaCy 在 spacy-lookups-data 中找不到语言 'en' 的 table(s) lexeme_norm

SpaCy can't find table(s) lexeme_norm for language 'en' in spacy-lookups-data

我正在尝试在 SpaCy 中训练文本分类管道:

import spacy

nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("textcat", last=True)
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != 'textcat']
with nlp.disable_pipes(*other_pipes):
    optimizer = nlp.begin_training()
    # training logic

但是,每次调用 nlp.begin_training() 时,我都会收到错误消息

ValueError: [E955] Can't find table(s) lexeme_norm for language 'en' in spacy-lookups-data. Make sure you have the package installed or provide your own lookup tables if no default lookups are available for your language.

运行 python3 -m spacy validate returns

✔ Loaded compatibility table

================= Installed pipeline packages (spaCy v3.0.3) =================
ℹ spaCy installation:
/xxx/xxx/xxx/env/lib/python3.8/site-packages/spacy

NAME             SPACY            VERSION                            
en_core_web_lg   >=3.0.0,<3.1.0   3.0.0   ✔
en_core_web_sm   >=3.0.0,<3.1.0   3.0.0   ✔

此外,我已经尝试安装 spacy-lookups-data 但没有成功。

我该如何解决这个错误?

不允许在预训练模型上调用 nlp.begin_training()。如果你想训练一个新模型,只需使用: nlp = spacy.blank('en') 而不是 nlp = spacy.load("en_core_web_sm")

但是,如果您想继续训练现有模型调用 optimizer = nlp.create_optimizer() 而不是 begin_training()