Second Mini Project

In this lesson, we will start our second mini project: a word analogy system.

Introduction to the project

In the previous lesson, we used word2vec vectors to create an odd one out project. In this lesson, we will go one step further and build a word analogies system.

In the word analogies task, we will basically try to complete the sentence A is to B as C is to ____. We try to find the value to be filled in the blank. For example, Man is to Woman as King is to Queen.

In other words, we are trying to find a word, D, such that the associated word vectors are related in the same manner.

B - A = D - C

We will measure the similarity between B - A and D - C using cosine_similarity. We are essentially trying to find a vector D which makes the values of both the expressions almost the same. So, we can derive one formula as follows:

B - A = D - C
D = B - A + C

Let’s first import the packages we require.

Get hands-on with 1200+ tech skills courses.