我正在尝试在space中训练文本分类管道:
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
返回
✔ 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()