howl-anderson / Chinese_models_for_SpaCy

SpaCy 中文模型 | Models for SpaCy that support Chinese
MIT License
645 stars 110 forks source link

zh_model.vectors is not a shortcut link in version 2.0.4 #6

Closed glfeng318 closed 6 years ago

glfeng318 commented 6 years ago
nlp = zh_core_web_sm.load()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-4-58e55b9e362b> in <module>()
      3 from spacy import displacy
      4 import zh_core_web_sm
----> 5 nlp = zh_core_web_sm.load()

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/zh_core_web_sm/__init__.py in load(**overrides)
     10 
     11 def load(**overrides):
---> 12     return load_model_from_init_py(__file__, **overrides)

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/util.py in load_model_from_init_py(init_file, **overrides)
    171     if not model_path.exists():
    172         raise IOError(Errors.E052.format(path=path2str(data_path)))
--> 173     return load_model_from_path(data_path, meta, **overrides)
    174 
    175 

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/util.py in load_model_from_path(model_path, meta, **overrides)
    154             component = nlp.create_pipe(name, config=config)
    155             nlp.add_pipe(component, name=name)
--> 156     return nlp.from_disk(model_path)
    157 
    158 

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/language.py in from_disk(self, path, disable)
    651         if not (path / 'vocab').exists():
    652             exclude['vocab'] = True
--> 653         util.from_disk(path, deserializers, exclude)
    654         self._path = path
    655         return self

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/util.py in from_disk(path, readers, exclude)
    509     for key, reader in readers.items():
    510         if key not in exclude:
--> 511             reader(path / key)
    512     return path
    513 

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/language.py in <lambda>(p, proc)
    647             if not hasattr(proc, 'to_disk'):
    648                 continue
--> 649             deserializers[name] = lambda p, proc=proc: proc.from_disk(p, vocab=False)
    650         exclude = {p: False for p in disable}
    651         if not (path / 'vocab').exists():

nn_parser.pyx in spacy.syntax.nn_parser.Parser.from_disk()

nn_parser.pyx in spacy.syntax.nn_parser.Parser.Model()

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/_ml.py in Tok2Vec(width, embed_size, **kwargs)
    276                           name='embed_shape')
    277         if pretrained_vectors is not None:
--> 278             glove = StaticVectors(pretrained_vectors, width, column=cols.index(ID))
    279 
    280             embed = uniqued(

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/thinc/neural/_classes/static_vectors.py in __init__(self, lang, nO, drop_factor, column)
     39         # same copy of spaCy if they're deserialised.
     40         self.lang = lang
---> 41         vectors = self.get_vectors()
     42         self.nM = vectors.shape[1]
     43         self.drop_factor = drop_factor

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/thinc/neural/_classes/static_vectors.py in get_vectors(self)
     50 
     51     def get_vectors(self):
---> 52         return get_vectors(self.ops, self.lang)
     53 
     54     def begin_update(self, ids, drop=0.):

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/thinc/extra/load_nlp.py in get_vectors(ops, lang)
     17     key = (ops.device, lang)
     18     if key not in VECTORS:
---> 19         nlp = get_spacy(lang)
     20         nV = max(lex.rank for lex in nlp.vocab)+1
     21         nM = nlp.vocab.vectors_length

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/thinc/extra/load_nlp.py in get_spacy(lang, **kwargs)
      9     import spacy
     10     if lang not in SPACY_MODELS:
---> 11         SPACY_MODELS[lang] = spacy.load(lang, **kwargs)
     12     return SPACY_MODELS[lang]
     13 

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/__init__.py in load(name, **overrides)
     13     if depr_path not in (True, False, None):
     14         deprecation_warning(Warnings.W001.format(path=depr_path))
---> 15     return util.load_model(name, **overrides)
     16 
     17 

~/.local/share/virtualenvs/ml-4jhPJgD9/lib/python3.6/site-packages/spacy/util.py in load_model(name, **overrides)
    117     elif hasattr(name, 'exists'):  # Path or Path-like to model data
    118         return load_model_from_path(name, **overrides)
--> 119     raise IOError(Errors.E050.format(name=name))
    120 
    121 

OSError: [E050] Can't find model 'zh_model.vectors'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
howl-anderson commented 6 years ago

@feng5 Sorry, this is a bug, I already found yesterday and already update the release file of version 2.0.4. You can download the new model file, sorry for the bug.