SpaCy 在 spacy-lookups-data 中找不到语言“en”的表 lexeme_norm

Pal*_*lle 4 python nlp spacy

我正在尝试在 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
Run Code Online (Sandbox Code Playgroud)

但是,每次我打电话时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.
Run Code Online (Sandbox Code Playgroud)

运行python3 -m spacy validate返回

? 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   ?
Run Code Online (Sandbox Code Playgroud)

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

我该如何解决这个错误?

kri*_*bek 7

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

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