当我们训练自定义模型时,我确实看到我们需要调整掉的参数和n_iter参数,但是Spacy使用什么深度学习算法来训练自定义模型呢?另外,当添加新的实体类型时,创建空白或在现有模型上进行培训是好的吗?
发布于 2020-02-25 12:04:59
spaCy使用哪种学习算法?
spaCy有自己的深度学习库,名为thinc,用于不同的NLP模型。对于大多数(如果不是全部)任务,spaCy使用了一个基于CNN的深度神经网络,并做了一些调整。专门用于命名实体识别,spacy使用:
- **Embed**: Words are embedded using a Bloom filter, which means that word hashes are kept as keys in the embedding dictionary, instead of the word itself. This maintains a more compact embeddings dictionary, with words potentially colliding and ending up with the same vector representations.- **Encode**: List of words is encoded into a sentence matrix, to take context into account. spaCy uses CNN for encoding.- **Attend**: Decide which parts are more informative given a query, and get problem specific representations.- **Predict**: spaCy uses a multi layer perceptron for inference.这一框架的优点是:
作为一个完整的概述,Matthew描述了该模型如何在这个YouTube视频中工作。幻灯片可以找到这里。
注:本信息基于2017年的幻灯片。从那以后引擎可能就变了。
当添加一个新的实体类型时,我们应该创建一个空白模型还是训练一个现有的模型?
理论上,当用新实体对spaCy模型进行微调时,您必须确保模型不会忘记以前学过的实体的表示。最好的办法,如果可能的话,就是从头开始训练一个模型,但由于缺乏数据或资源,这可能并不容易,也不可能。
编辑2021年2月:spaCy版本3现在使用变压器体系结构作为其深度学习模型。
https://stackoverflow.com/questions/60381170
复制相似问题