SpaCy: how to load Google news word2vec vectors?

后端 未结 4 1649
面向向阳花
面向向阳花 2020-12-25 13:48

I\'ve tried several methods of loading the google news word2vec vectors (https://code.google.com/archive/p/word2vec/):

en_nlp = spacy.load(\'en\',vector=Fals         


        
4条回答
  •  旧巷少年郎
    2020-12-25 13:56

    I am using spaCy v2.0.10.

    Create a SpaCy compatible binary file:

    spacy.vocab.write_binary_vectors('googlenews.txt.bz2','googlenews.bin')
    

    I want to highlight that the specific code in the accepted answer is not working now. I encountered "AttributeError: ..." when I run the code.

    This has changed in spaCy v2. write_binary_vectors was removed in v2. From spaCy documentations, the current way to do this is as follows:

    $ python -m spacy init-model en /path/to/output -v /path/to/vectors.bin.tar.gz
    

提交回复
热议问题