nlp的word2vec中如何把英文片語向量化?
比如 sit on,stand on如何直接利用模型把它向量化。
相加,平均都可以,
放到各種encoder里取輸出向量也可以
不是很懂nlp 但是看看glove 這些paper不就行了
相加取均值可以是可以,但效果肯定不如訓練Word2Vec的時候直接把片語當做一個詞進行訓練效果好,這樣片語可以直接使用周圍詞的向量表示
有論文用下劃線把片語間單詞連接,作為一個單詞整體進行word2vec訓練。
For instance in 「2 tbsp of olive oil」 the olive_oil is extracted as the ingredient name and treated as a single word for word2vec computation.
Salvador, A., Hynes, N., Aytar, Y., Marin, J., Ofli, F., Weber, I., Torralba, A. (2017). Recipe1M+: A Dataset for Learning Cross-Modal Embeddings for Cooking Recipes and Food Images. Proceedings - 30th IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, 2017-Janua(X), 3068–3076. https://doi.org/10.1109/CVPR.2017.327
- 想要直接獲得 sit on 的向量
word2vec 中tokenizer 可以進行修改,分詞的結果不是針對單詞,可直接分詞得到sit on
2. 對於單個單詞的tokenizer
可以將sit 和 on embedding 向量相加,求平均(通常),做pooling max 等操作。
pytorch 可以通過nn.EmbeddingBag() 得到。
w2v相加即可
推薦閱讀: