- Word vectors try to represent meaning of words
- Words which appear in similar context have similar vectors
This will require training word vectors based on a huge corpus of data.
We can use pretrained word vectors using the glove algorithm, Spacy library in python makes it easy to work with.
word vectors tpically have a lenth of few hundreds elements dimensions for word vectors
first pass the string to the nlp object
Using token we iterate over and try to print first few dimensions of the vector
actual values dont matter; what matters is how similar they are to other words
- Direction of vectors matters
- “Distance” between words = angle between the vectors
- Cosine similarity
- 1: If vectors point in the same direction
- 0: If they are perpendicular
- -1: If they point in opposite directions
In : doc.similarity(nlp(“dog”))