我想使用 spaCy v3 训练一个自定义 NER 模型我准备了我的训练数据并使用了这个脚本
import spacy
from spacy.tokens import DocBin
nlp = spacy.blank("en") # load a new spacy model
db = DocBin() # create a DocBin object
for text, annot in tqdm(TRAIN_DATA): # data in previous format
doc = nlp.make_doc(text) # create doc object from text
ents = []
for start, end, label in annot["entities"]: # add character indexes
span = doc.char_span(start, end, label=label)
if span is None:
pass
else:
ents.append(span)
doc.ents = ents # label the text with the ents
db.add(doc)
db.to_disk("./train.spacy") # save the docbin object
然后它打印这个错误:
AttributeError: 'DocBin' object has no attribute 'to_disk'