Fun with word vectors

Now that we have condensed words (tokens) into vectors of numbers, we can have some fun with them. A few classic examples from the original Google paper that you can try for yourself are as follows:

  • Mathematical operations: As mentioned earlier, the canonical example of this is v(King) - v(Man) + v(Woman) ~ v(Queen). Using simple addition, such as v(software) + v(engineer), we can come up with some fascinating relationships; here are a few more examples:
  • Similarity: Given that we are working with a vector space, we can use the cosine similarity to compare one token against many in order to see similar tokens. For example, similar words to v(Spark) might be v(MLlib), v(scala), v(graphex), and so on.
  • Matches/Not Matches: Which words from a given list do not go together? For example, doesn't_match[v(lunch, dinner, breakfast, Tokyo)] == v(Tokyo).
  • A is to B as C is to ?: As per the Google paper, here is a list of word comparisons that are made possible by using the skip-gram implementation of word2vec:
..................Content has been hidden....................

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