【问题标题】:Evaluating Word2Vec model by finding linear algebraic structure of words通过寻找词的线性代数结构来评估 Word2Vec 模型
【发布时间】:2017-08-12 06:53:55
【问题描述】:

我已经在 python 中使用 gensim 库构建了 Word2Vecmodel。我想按如下方式评估我的词嵌入

如果A与B有关,C与D有关,则A-C+B应等于D。例如“India”-“Rupee”+“Japan”的embedding向量算术应等于“日元”的嵌入。

我已经在 gensim 的内置函数中使用过 predict_output_word、most_similar 但无法获得想要的结果。

new_model.predict_output_word(['india','rupee','japan'],topn=10)
new_model.most_similar(positive=['india', 'rupee'], negative=['japan'])

请帮助我根据上述标准评估我的模型。

【问题讨论】:

    标签: nlp word2vec word-embedding


    【解决方案1】:

    您应该以与accuracy() 方法相同的方式使用most_similar() 方法的positivenegative 参数:

    https://github.com/RaRe-Technologies/gensim/blob/718b1c6bd1a8a98625993d73b83d98baf385752d/gensim/models/keyedvectors.py#L697

    具体来说,如果您有“A 之于 B 就像 C 之于 [预期]”的类比,您应该查看:

    results = model.most_similar(positive=[word_b, word_c], negative=[word_a])
    

    或者在你的例子中:

    results = model.most_similar(positive=['rupee', 'japan'], negative=['india'])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-09
      • 2020-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多