我已经有了一个现有的spaCy模型,我想在运行时用额外的训练数据来改进它。
例如,我的训练模型中的训练dataSet如下所示:
text="Anna lives in Munich and works at BMW"
entity: name=Anna
entity: city=Munich
entity: company=BMW
在我的实现中,在开始新的训练之前,我从现有模型中获取ner:
nlp = spacy.load(modelPath)
ner = nlp.get_pipe('ner')
然后我用新的TrainingData训练我现有
我想创建一个自定义的NER模型。我就是这么做的:
培训数据(斯坦福-ner.tsv):
Hello O
! O
My O
name O
is O
Damiano PERSON
. O
PROPERTIES (斯坦福-ner.prop):
trainFile = stanford-ner.tsv
serializeTo = ner-model.ser.gz
map = word=0,answer=1
maxLeft=1
useClassFeature=true
useWord=true
useNGrams=true
noMidNGrams=true
ma
我仍然在学习Python和模型的创建,并且对使用Spacy的NLP非常陌生。我用训练了Spacy现有的模型-- en_core_web_sm。
我已经用我的领域特定实体来训练这个模型。
def main(model="en_core_web_sm", new_model_name="new_ner_model", output_dir='/content/drive/My Drive/Data/new_model', n_iter=100):
.
.
(code to train the model)
.
.
# save model t
我正试着训练新的实体为斯佩西纳。我尝试将我的新实体添加到现有的spacy 'en‘模型中。然而,这影响了'en'和我的新实体的预测模型。
因此,我建立了一个空白模型并训练了实体识别。这个效果很好。然而,它只能预测我训练过的对象,而不能预测常规的spacy实体识别。
比如说我把“马”训练成动物实体。
对于给定的文本
txt ='Did you know that George bought those horses for 10000 dollars?'
我期待着下列实体得到认可
George - PERSON
horses - ANIMAL
10000
我一直在一些文本上训练我的NER模型,并试图在其中找到具有自定义实体的城市。
示例:-
('paragraph Designated Offices Party A New York Party B Delaware paragraph pricing source calculation Market Value shall generally accepted pricing source reasonably agreed parties paragraph Spot rate Spot Rate specified paragraph reasonably agreed