1
$\begingroup$

I am trying out my hand at training a Word2Vec model using gensim. I made a simple training file that basically had just one line repeated multiple times

entertainment films Movies cinema
entertainment Movies 
entertainment films
entertainment cinema

The idea behind using a training file like the one above is to ensure that words like movies, etc come out to be most similar to entertainment.

>>> wv_model = gensim.models.Word2Vec(sents, size=300, min_count=1, 
    workers=8, window=1, sg=0)

But when I check the results I entertainment actually has a negative similarity score

>>> wv_model.most_similar(positive=['Movies'])
[('cinema', 0.14602532982826233), ('films', -0.022810805588960648), ('entertainment', -0.030070479959249496)]

The result I am trying to achieve is to ensure that the most similar word for movies, films, cinema comes out to be entertainment. How do I do this?

$\endgroup$

1 Answer 1

1
$\begingroup$

I am trying out my hand at training a Word2Vec model using gensim. I made a simple training file that basically had just one line repeated multiple times

entertainment films Movies cinema
entertainment Movies 
entertainment films
entertainment cinema

Here you are basically trying to hack Word2Vec to give you the answers you want it to give. Depending on how exactly you create the dataset, this could give results of different quality. But the bigger problem is that when you apply this algorithm to real-life data, the distribution of the data would be very different from what the algorithm was trained on, hence the results may be surprising...

A much better approach would be to gather realistic real-life data and use it to train the algorithm. You always want the training data to be similar to the data that your algorithm will see in prediction time.

The idea behind using a training file like the one above is to ensure that words like movies, etc come out to be most similar to entertainment.

But you're not doing this! What Word2Vec does (see also here for nice tutorial) is

The result is a set of word-vectors where vectors close together in vector space have similar meanings based on context, and word-vectors distant to each other have differing meanings. For example, strong and powerful would be close together and strong and Paris would be relatively far.

In your data Movies, cinema, and films are similar because they appear in a similar context, that is, together with entertainment. On another hand, entertainment in this dataset is like a stopword in a natural language dataset, same as the or and it appears in all kinds of contexts, so it's not similar to anything in particular.

A simple way to learn such algorithm synonyms is to take natural language data and use it to create artificial data with such synonyms. For example, have in your training sample sentences "I went to [cinema] to see the [movie] Casablanca" and "I went to [movie theater] to see the [film] Casablanca", and other combinations. This of course doesn't solve the problem with the word entertainment, since it's not a synonym. To learn the relation between the words entertainment and cinema, gather data where those words appear together, like the movie reviews, press articles from the Arts & Culture category, etc.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.