Q:

How does Word2Vec ensure that antonyms will be far apart in the vector space

Broadly speaking the training of word2vec is a process in which words that are often in the same context are clustered together in the vector space. We start by randomly shuffling the words on the plane and then with each iteration more and more clusters form. I think I understood this but how can we assure that the words that are antonyms or rarely appear in the same context don't end up in clusters that are close by? Also how can we know that words that are more irrelevant are farther away than word that are less irrelevant.

A:

There is no guarantee that antonyms will be far apart -- it's just one of the "nice" properties that falls out as a result of the procedure. The main premise of word2vec is called the "distributional hypothesis" -- related things will tend to appear together (and, implicitly, that unrelated things do not appear together). If that hypothesis is valid for your data, then you'll find that word2vec works well. Otherwise, you'll have to try something else.
One case where antonyms will appear in context together is in a sentence contrasting two alternatives. Carl provides a nice example in his comment: "Cold today and warm tomorrow." With respect to temperature, "cold" and "warm" are opposites. With respect to time, "today" and "tomorrow" are also opposite. Yet in this sentence, both pairs appear nearby.

