【问题标题】:Better way to combine Word embedding to get embedding of a sentence结合词嵌入以获得句子嵌入的更好方法
【发布时间】:2019-01-20 09:23:55
【问题描述】:

我在许多 kaggle 内核和教程中看到,平均词嵌入被认为是一个句子的嵌入。但是,我想知道这是否是一种正确的方法。因为它丢弃了句子中单词的位置信息。有没有更好的方法来结合嵌入?也许以特定的方式将它们分层组合?

【问题讨论】:

    标签: deep-learning nlp text-processing word-embedding


    【解决方案1】:

    如果您需要一种简单但有效的方法,Sif embedding 非常适合。它对一个句子中的词向量进行平均,并删除它的第一个主成分。它比平均词向量要好得多。可在线获取代码here。这是主要部分:

    svd = TruncatedSVD(n_components=1, random_state=rand_seed, n_iter=20)
    svd.fit(all_vector_representation)
    svd = svd.components_
    
    XX2 = all_vector_representation - all_vector_representation.dot(svd.transpose()) * svd
    

    all_vector_representation 是数据集中所有句子的平均嵌入。

    还存在其他复杂的方法,例如 ELMOTransformer 等。

    【讨论】:

    • 删除第一个组件背后的直觉是什么。它是否消除了某种人口分层?
    猜你喜欢
    • 2020-04-07
    • 1970-01-01
    • 2019-05-16
    • 2021-09-14
    • 2020-07-04
    • 2021-11-29
    • 2020-03-20
    • 1970-01-01
    • 2019-11-26
    相关资源
    最近更新 更多