Natural language processing with deep learning is an important combination. Using word vector representations and embedding layers you can train recurrent neural networks with outstanding performances in a wide variety of industries. Examples of applications are sentiment analysis, named entity recognition and machine translation.
One of the most fascinating properties of word embeddings is that they can also help with analogy reasoning. While analogy reasoning may not be by itself the most important NLP application, but it might help convey a sense of what these word embeddings can do.
Analogies example:
Given this word embeddings table:
Can we conclude this relation:
Lets subtract eMan from eWoman. This will equal the vector [-2 0 0 0]
Similar eKing - eQueen = [-2 0 0 0]
So the difference is about the gender in both.
So we can reformulate the problem to find:
It turns out that eQueen is the best solution here that gets the the similar vector.
Cosine similarity - the most commonly used similarity function:
CosineSimilarity(u, v)
= u . v
/ ||u|| ||v||
= cos(θ)u
and v
vectors. It will be large if the vectors are very similar.You can also use Euclidean distance as a similarity function (but it rather measures a dissimilarity, so you should take it with negative sign).
We can use this equation to calculate the similarities between word embeddings and on the analogy problem where u
= ew and v
= eking - eman + ewoman
E
of the shape (300, 10000) in case we are extracting 300 features.
E
,O6257) = e6257 which shape is (300, 1).E
, Oj) = ejE
randomly and then try to learn all the parameters of this matrix.embedding layer
that extracts this column with no multiplication.