【问题标题】:How to search Word2Vec or GloVe Embedding to find words by semantic relationship如何通过语义关系搜索 Word2Vec 或 GloVe Embedding 来查找单词
【发布时间】:2018-02-20 03:10:13
【问题描述】:

展示 Word Embedding 优势的常见例子是展示一些单词之间的语义关系,例如king:queen = male:female。这种关系如何被发现?那是通过某种基于几何聚类的可视化吗?任何指针将不胜感激。

【问题讨论】:

  • 也许 gensim's word2vec 提供 most_similar 方法可以为您完成这项工作。

标签: machine-learning nlp keras word2vec word-embedding


【解决方案1】:

如果“发现”是指监督学习,则datasets 包含许多已提取的关系,例如“city-in-state”、“capital-world”、“最高级”等

此数据集是词向量内在评估的热门选择 在完成词向量类比。另见this question

有效无监督提取这些关系可能很棘手。一个简单的算法需要 O(n2) 时间和内存,其中 n 是词汇表中的单词数,非常大。一般来说,这个问题归结为高效的索引构建。

但如果你只想自己训练它并使用词嵌入,你可以简单地使用gensim

model = gensim.models.word2vec.Word2Vec(sentences=sentences, size=100, window=4,
                                        workers=5, sg=1, min_count=20, iter=10)
word_vectors = model.wv
similar = word_vectors.most_similar(positive=['woman', 'king'], negative=['man'])
# [(u'queen', 0.7188869714736938), (u'empress', 0.6739267110824585), ...

请注意,您需要一个大型语料库,例如 text8

【讨论】:

    猜你喜欢
    • 2013-11-09
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 2021-07-21
    • 2019-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多