如何为货币重新训练现有的 spacy NER 模型

How to re-train an existing spacy NER model for currency

我正在尝试使用 "euro"、"rupees"、"eu"、"Rs." 等不同国家/地区的货币更新现有的 spacy 模型 "en_core_web_sm" "INR" 等。我怎样才能做到这一点? spacy 教程对我没有太大帮助,因为训练 "horses" 等固定字符串,因为 "ANIMAL" 似乎与我的要求不同。原因是我可以使用不同格式的货币值:“100 万欧元”、"Rs. 10,000"、"INR 1 thousand" 等。我的样本数据集包含大约 1000 个样本,格式如下:

TRAIN_DATA = [      
 (" You have activated International transaction limit for Debit Card ending XXXX1137 on 2017-07-05 12:48:20.0 via NetBanking. The new limit is Rs. 250,000.00", {'entities' : [(140, 154, 'MONEY')] }),...
]

谁能帮我解决数据格式、训练大小或任何其他相关信息的问题?

文档中的示例应该适合您。我稍微改变了它以匹配您的变量名称。

optimizer = nlp.begin_training()

for itn in range(100):
    random.shuffle(train_data)
    for raw_text, entity_offsets in TRAIN_DATA:
        doc = nlp.make_doc(raw_text)
        gold = GoldParse(doc, entities=entity_offsets)
        nlp.update([doc], [gold], drop=0.5, sgd=optimizer)
nlp.to_disk('/model')

Link to Documentation