word2vec - what is best? add, concatenate or average word vectors?

空扰寡人 提交于 2020-05-25 06:41:22

问题


I am working on a recurrent language model. To learn word embeddings that can be used to initialize my language model, I am using gensim's word2vec model. After training, the word2vec model holds two vectors for each word in the vocabulary: the word embedding (rows of input/hidden matrix) and the context embedding (columns of hidden/output matrix).

As outlined in this post there are at least three common ways to combine these two embedding vectors:

  1. summing the context and word vector for each word
  2. summing & averaging
  3. concatenating the context and word vector

However, I couldn't find proper papers or reports on the best strategy. So my questions are:

  1. Is there a common solution whether to sum, average or concatenate the vectors?
  2. Or does the best way depend entirely on the task in question? If so, what strategy is best for a word-level language model?
  3. Why combine the vectors at all? Why not use the "original" word embeddings for each word, i.e. those contained in the weight matrix between input and hidden neurons.

Related (but unanswered) questions:

  • word2vec: Summing/concatenate inside and outside vector
  • why we use input-hidden weight matrix to be the word vectors instead of hidden-output weight matrix?

回答1:


I have found an answer in the Stanford lecture "Deep Learning for Natural Language Processing" (Lecture 2, March 2016). It's available here. In minute 46 Richard Socher states that the common way is to average the two word vectors.




回答2:


You should read this research work at-least once to get the whole idea of combining word embeddings using different algebraic operators. It was my research.

In this paper you can also see the other methods to combine word vectors.

In short L1-Normalized average word vectors and sum of words are good representations.




回答3:


I don't know any work that empirically tests different ways of combining the two vectors, but there is a highly influencial paper comparing: 1) just use the word vector, and 2) adding up word and context vector. The paper is here: https://www.aclweb.org/anthology/Q15-1016/.

First, note that the metric is analogy and similarity tests, NOT downstream tasks.

Here is a quote from the paper:

for both SGNS and GloVe, it is worthwhile to experiment with the w + c variant [adding up word and context vectors], which is cheap to apply (does not require retraining) and can result in substantial gains (as well as substantial losses).

So I guess you just need to try it out on your specific task.

By the way, here is a post on how to get context vectors from gensim: link




回答4:


I thought I attempt to answer based on the comments.

The question you are linking to is: "WordVectors How to concatenate word vectors to form sentence vector"

Word vectors can be compared on its own. But often one wants to put the sentence, paragraph or a document in context - i.e. a collection of words. And then the question arises how to combine those to a single vector (gensim provides doc2vec for that use case).

That doesn't seem to be applicable in your case and I would just work with the given word vectors. You can adjust parameters like the size of the embedding, the training data, other algorithms. You could even combine vectors from different algorithms to create a kind of 'ensemble vector' (e.g. word2vec with GloVe). But it may not be more efficient.

Sometimes in language the same word has a different meaning depending on the type of word within a sentence or a combination of words. e.g. 'game' has a different meaning to 'fair game'. Sense2Vec offers a proposal to generate word vectors for those compound words: https://explosion.ai/blog/sense2vec-with-spacy (Of course, in that case you already need something that understands the sentence structure, such as SpaCy)



来源:https://stackoverflow.com/questions/46889727/word2vec-what-is-best-add-concatenate-or-average-word-vectors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!