<h2>Which learning algorithm does spaCy use?</h2>
<p>spaCy has its own deep learning library called <a href="https://github.com/explosion/thinc" rel="noreferrer">thinc</a> used under the hood for different NLP models. for most (if not all) tasks, spaCy uses a deep neural network based on CNN with a few tweaks. Specifically for Named Entity Recognition, spacy uses:</p>
<ol>
<li><p>A <strong>transition based approach</strong> borrowed from shift-reduce parsers, which is described in the paper <a href="https://arxiv.org/pdf/1603.01360.pdf" rel="noreferrer">Neural Architectures for Named Entity Recognition</a> by Lample et al.
Matthew Honnibal describes how spaCy uses this on a <a href="https://youtu.be/sqDHBH9IjRU?t=975" rel="noreferrer">YouTube video</a>.</p>
</li>
<li><p>A framework that's called <strong>&quot;Embed. Encode. Attend. Predict&quot;</strong> (Starting <a href="https://youtu.be/sqDHBH9IjRU?t=1254" rel="noreferrer">here</a> on the video), slides <a href="https://github.com/explosion/talks/blob/master/2018-04-12_Embed-Encode-Attend-Predict.pdf" rel="noreferrer">here</a>.</p>
<ul>
<li><p><strong>Embed</strong>: 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.</p>
</li>
<li><p><strong>Encode</strong>: List of words is encoded into a sentence matrix, to take context into account. spaCy uses CNN for encoding.</p>
</li>
<li><p><strong>Attend</strong>: Decide which parts are more informative given a query, and get problem specific representations.</p>
</li>
<li><p><strong>Predict</strong>: spaCy uses a multi layer perceptron for inference.</p>
</li>
</ul>
</li>
</ol>
<p>Advantages of this framework, per Honnibal are:</p>
<ol>
<li>Mostly equivalent to sequence tagging (another task spaCy offers models for)</li>
<li>Shares code with the parser</li>
<li>Easily excludes invalid sequences</li>
<li>Arbitrary features are easily defined</li>
</ol>
<p>For a full overview, Matthew Honnibal describes how the model works in <a href="https://www.youtube.com/watch?v=sqDHBH9IjRU" rel="noreferrer">this YouTube video</a>. Slides could be found <a href="https://github.com/explosion/talks/blob/master/2017-11-02_Practical-and-Effective-Neural-NER.pdf" rel="noreferrer">here</a>.</p>
<p><em>Note</em>: This information is based on slides from 2017. The engine might have changed since then.</p>
<h2>When adding a new entity type, should we create a blank model or train an existing one?</h2>
<p>Theoretically, when fine-tuning a spaCy model with new entities, you have to make sure the model doesn't forget representations for previously learned entities. The best thing, if possible, is to train a model from scratch, but that might not be easy or possible due to lack of data or resources.</p>
<p><strong>EDIT Feb 2021</strong>: spaCy version 3 now uses the Transformer architecture as its deep learning model.</p>
Which Deep Learning Algorithm does Spacy uses when we train Custom model?
<p>When we train custom model, I do see we have dropout and n_iter parameters to tune, but which deep learning algorithm does Spacy Uses to train Custom Models? Also, when Adding new Entity type is it good to create blank or train it on existing model?</p>