DEV Community

Cover image for Understanding Word2Vec: Teaching Neural Networks to Understand Words
Rijul Rajesh
Rijul Rajesh

Posted on

Understanding Word2Vec: Teaching Neural Networks to Understand Words

As humans, we use words to communicate, but in the case of machines we are usually accustomed to hearing about 0s and 1s.

Now what about machine learning algorithms, which are essentially trying to simulate aspects of how our brains work?

Many machine learning algorithms, including neural networks, do not work well with raw words.

So if you want to plug words into a neural network or some other machine learning algorithm, we need a way to convert those words into numbers.

One simple way to convert words to numbers is to assign each word a random number.

For example, someone watched the movie The Incredibles and said:

"The Incredibles is great!"

We can give each word a random number.

Now, if we want to create another sentence like:

"The Incredibles is awesome!"

We can reuse the existing numbers and only assign a new number for "awesome".

However, this approach has a disadvantage.

Even though "great" and "awesome" have very similar meanings, the numbers assigned to them are completely different and unrelated.

Because of this, the neural network needs more complexity and more training. Learning how to correctly process the word "great" does not help the neural network understand the word "awesome".

Ideally, similar words that are used in similar ways should be represented by similar numbers. This way, learning how to use one word can also help the model learn how to use another.

There is another challenge as well.

The same word can have different meanings depending on the context.

For example, the word "great" can be used in a positive way:

"The food is great!"

Or it can be used in a negative way:

"My shoes got dirty. Great."

So it would be useful if we had a representation that could capture both the positive and negative ways the word "great" is used, depending on the context.

All of this may sound complex, but we can use a simple neural network to learn these relationships for us.

We will explore how this works in the next article.

Looking for an easier way to install tools, libraries, or entire repositories?
Try Installerpedia: a community-driven, structured installation platform that lets you install almost anything with minimal hassle and clear, reliable guidance.

Just run:

ipm install repo-name
Enter fullscreen mode Exit fullscreen mode

… and you’re done! πŸš€

Installerpedia Screenshot

πŸ”— Explore Installerpedia here

Top comments (0)