Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpaCy: How to get the spacy model name?

Tags:

python

spacy

It doesn't show up in pip list

zeke$ pip list | grep spacy
spacy (1.7.3)

How do I get the name of the model?


I tried this but it doesn't work

echo "spaCy model:"
python3 -m sputnik --name spacy find

Throws up this error:

zeke$ python3 -m sputnik --name spacy find
Traceback (most recent call last):
  File "/Users/zeke/anaconda/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/zeke/anaconda/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__main__.py", line 28, in <module>
    main()
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__main__.py", line 12, in main
    args.run(args)
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/cli.py", line 89, in run
    data_path=args.data_path)
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/__init__.py", line 114, in find
    obj = cls(app_name, app_version, expand_path(data_path))
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/pool.py", line 19, in __init__
    super(Pool, self).__init__(app_name, app_version, path, **kwargs)
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 33, in __init__
    self.load()
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 51, in load
    for package in self.packages():
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package_list.py", line 47, in packages
    yield self.__class__.package_class(path=os.path.join(self.path, path))
  File "/Users/zeke/anaconda/lib/python3.5/site-packages/sputnik/package.py", line 15, in __init__
    super(Package, self).__init__(defaults=meta['package'])
KeyError: 'package'
like image 536
Saravanabalagi Ramachandran Avatar asked Mar 28 '17 14:03

Saravanabalagi Ramachandran


People also ask

How do I know what model spaCy I have?

You can also do python -m spacy info . If you're updating an existing installation, you might want to run python -m spacy validate , to check that the models you already have are compatible with the version you just installed.

How do I get my spaCy model from local?

To load a pipeline from a data directory, you can use spacy. load() with the local path. This will look for a config. cfg in the directory and use the lang and pipeline settings to initialize a Language class with a processing pipeline and load in the model data.

Which model does spaCy use?

EDIT Feb 2021: spaCy version 3 now uses the Transformer architecture as its deep learning model.


1 Answers

The sputnik package manager is deprecated as of spaCy version 1.7.0. In your version, you should be able to see all installed / linked models using spacy info:

python -m spacy info     # info about spaCy and installed models
python -m spacy info en  # info about model with the shortcut link 'en'

All model meta is also exposed as the meta attribute of the Language class, so from within your script, you can do:

nlp = spacy.load('en') # or any other model
print(nlp.meta['name'])

If you have downloaded models via spaCy's new download command, they'll be installed as pip packages. This means that they should show up when you run pip list or pip freeze from within the same environment.

Note that models are not downloaded automatically when you install spaCy, so you have to download them separately (see the docs for a list of available models):

python -m spacy download en              # default English model (~50MB)
python -m spacy download en_core_web_md  # larger English model (~1GB)
like image 181
Ines Montani Avatar answered Oct 01 '22 11:10

Ines Montani