Word2Vec

Word2Vec is one of the widely used embedding techniques in the area of NLP. This model creates real-valued vectors from input text by looking at the contextual information the input word appears in. So, you will find out that similar words will be mentioned in very similar contexts, and hence the model will learn that those two words should be placed close to each other in the particular embedding space.

From the statements in the following diagram, the model will learn that the words love and adore share very similar contexts and should be placed very close to each other in the resulting vector space. The context of like could be a bit similar as well to the word love, but it won't be as close to love as the word adore:

Figure 15.2: Sample of sentiment sentences

The Word2Vec model also relies on semantic features of input sentences; for example, the two words adore and love are mainly used in a positive context and usually precede noun phrases or nouns. Again, the model will learn that these two words have something in common and it will be more likely to put the vector representation of these two vectors in a similar context. So, the structure of the sentence will tell the Word2Vec model a lot about similar words.

In practice, people feed a large corpus of text to the Word2Vec model. The model will learn to produce similar vectors for similar words, and it will do so for each unique word in the input text.

All of these words' vectors will be combined and the final output will be an embedding matrix where each row represents the real-valued vector representation of a specific unique word.

Figure 15.3: Example of Word2Vec model pipeline

So, the final output of the model will be an embedding matrix for all the unique words in the training corpus. Usually, good embedding matrices could contain millions of real-valued vectors.
Word2Vec modeling uses a window to scan the sentence and then tries to predict the vector of the middle word of that window based on its contextual information; the Word2Vec model will scan a sentence at a time. Similar to any machine learning technique, we need to define a cost function for the Word2Vec model and its corresponding optimization criteria that will make the model capable of generating real-valued vectors for each unique image and also relate the vectors to each other based on their contextual information

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset