2 years ago
#42894
Navdeep
Accessing fasttext vectors in spaCy
I have converted the fasttext vectors into spacy format using init
command. It has been done successfully as shown below;
ℹ Creating blank nlp object for language 'en'
✔ Successfully converted 400873 vectors
✔ Saved nlp object with vectors to output directory. You can now use the path to
it in your config as the 'vectors' setting in [initialize].
E:\Spacy\output_dir
Here it says that I have to set the path of vectors to E:\Spacy\output_dir in config.cfg file. Now there are two config.cfg files, one default file and the other one created in the E:\Spacy\output_dir . Which one to update? I have updated the default one and executed the following code;
import spacy
nlp = spacy.blank('en')
#print(nlp.initialize())
nlp.vocab['ਵਿਭਾਗ'].vector
In this code, I am trying to access vectors but it is giving the following error;
ValueError: [E010] Word vectors set to length 0. This may be because you don't have a model installed or loaded, or because your model doesn't include word vectors. For more info, see the docs:
https://spacy.io/usage/models
Where am I making the mistake?
When I am using the following code I am able to see the vectors;
import spacy
nlp = spacy.load('E:\Spacy\output_dir')
#print(len(nlp.vocab.strings))
nlp.vocab['ਵਿਭਾਗ'].vector
Can't I access the vectors without loading the model? What for is vectors
inside the config.cfg then? Please explain.
nlp
nltk
spacy
fasttext
spacy-3
0 Answers
Your Answer