What's the point of downloading 'models' when using SpaCy?

Viewed 3420

What does the model do?

I see the term floating around in regards to NLP and ML in general, and there seems to be no one specific definition.

What do the models accomplish in regards to NLP and SpaCy?

import spacy
from spacy import displacy

nlp = spacy.load('en_core_web_sm')
doc = nlp(u'This is a sentence.')
displacy.serve(doc, style='dep', options={'compact': True})
3 Answers

The spaCy 101 guide has a section on this – see here:

While some of spaCy's features work independently, others require statistical models to be loaded, which enable spaCy to predict linguistic annotations – for example, whether a word is a verb or a noun. spaCy currently offers statistical models for 8 languages, which can be installed as individual Python modules. Models can differ in size, speed, memory usage, accuracy and the data they include. The model you choose always depends on your use case and the texts you're working with. For a general-purpose use case, the small, default models are always a good start. They typically include the following components:

  • Binary weights for the part-of-speech tagger, dependency parser and named entity recognizer to predict those annotations in context.
  • Lexical entries in the vocabulary, i.e. words and their context-independent attributes like the shape or spelling.
  • Word vectors, i.e. multi-dimensional meaning representations of words that let you determine how similar they are to each other.
  • Configuration options, like the language and processing pipeline settings, to put spaCy in the correct state when you load in the model.

Not sure about SpaCy in particular, but in ML usually refers to the (mathematical?) model of your learning algorithm. From Wikipedia:

[Machine learning] Evolved from the study of pattern recognition and 
computational learning theory in artificial intelligence, machine learning 
explores the study and construction of algorithms that can learn from and make 
predictions on data – such algorithms overcome following strictly static 
program instructions by making data-driven predictions or decisions, through 
building a ***model*** from sample inputs.

For example, in neural networks, the model would consist of the weights and activation functions and the way they are put together. The model is what you train, and when trained, the model makes your predictions. It is your ML program, or at least the ML part of it, if you like.

Spacy is not fully-independently equipped with all the models.

Although it independently takes care of most of the features but yeah for use cases requiring the heed to predict linguistic annotations, additional statistical models need to be loaded as individual modules.

I suppose since the extra modules fit only on specific use cases, maybe this is why the spacy team chose to not to keep up with the auxiliary spaCy modules.

Related