'Error while loading vector from Glove in Spacy
I am facing the following attribute error when loading glove model:
Code used to load model:
nlp = spacy.load('en_core_web_sm')
tokenizer = spacy.load('en_core_web_sm', disable=['tagger','parser', 'ner', 'textcat'])
nlp.vocab.vectors.from_glove('../models/GloVe')
Getting the following atribute error when trying to load the glove model:
AttributeError: 'spacy.vectors.Vectors' object has no attribute 'from_glove'
Have tried to search on StackOverflow and elsewhere but can't seem to find the solution. Thanks!
From pip list:
- spacy version: 3.1.4
- spacy-legacy 3.0.8
- en-core-web-sm 3.1.0
Solution 1:[1]
Use spacy init vectors to load vectors from word2vec/glove text format into a new pipeline: https://spacy.io/api/cli#init-vectors
Solution 2:[2]
spacy version: 3.1.4 does not have the feature from_glove.
I was able to use nlp.vocab.vectors.from_glove() in spacy version: 2.2.4.
If you want, you can change your spacy version by using:
!pip install spacy==2.2.4 on your Jupyter cell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aab |
| Solution 2 | Talha Tayyab |
