Inspecting word vectors
In this exercise, you'll use a larger English model, which includes around 20.000 word vectors. Because vectors take a little longer to load, we're using a slightly compressed version of it than the one you can download with spaCy. The model is already pre-installed, and spacy
has already been imported for you.
This exercise is part of the course
Advanced NLP with spaCy
Exercise instructions
- Load the medium
'en_core_web_md'
model with word vectors. - Print the vector for
"bananas"
using thetoken.vector
attribute.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the en_core_web_md model
nlp = ____
# Process a text
doc = nlp("Two bananas in pyjamas")
# Get the vector for the token "bananas"
bananas_vector = ____.____
print(bananas_vector)