The amazing power of word vectors | the morning paper (acolyer.org)

What is a word vector?

At one level, it’s simply a vector of weights. In a simple 1-of-N (or ‘one-hot’) encoding every element in the vector is associated with a word in the vocabulary. The encoding of a given word is simply the vector in which the corresponding element is set to one, and all other elements are zero.

从某种角度来说,词向量(word vector)仅仅是对应单词的权重用的向量化表示。在独热编码中,向量中的每个编码元素与一个文本对应的词汇表中的特定的一个单词有联系,一个单词会对应一个独热向量,这个独热向量中对应这个单词的维度的元素会被置为1,其余的全都置为0.

Suppose our vocabulary has only five words: King, Queen, Man, Woman, and Child. We could encode the word ‘Queen’ as:

假设我们的词汇表只有5个单词,国王、女王、男人、女人和孩子,那么我们可以把“女王”编码为:

Using such an encoding, there’s no meaningful comparison we can make between word vectors other than equality testing.

但是这样的编码会使得两个向量之间没有什么比较意义,除了判断两个向量是否相等。

In word2vec, a distributed representation of a word is used. Take a vector with several hundred dimensions (say 1000). Each word is representated by a distribution of weights across those elements. So instead of a one-to-one mapping between an element in the vector and a word, the representation of a word is spread across all of the elements in the vector, and each element in the vector contributes to the definition of many words.

在word2vec中,我们对单词使用了一种数值分散(非零数值分散)的表示方法。假设一个向量有好几百维(比如1000维),每个单词都会被1000个权重表示,这些权重很有可能非零而且表示的是与其他单词的关系的大小。所以一个单词的表示会与这个1000维的向量的所有其他元素都有关系,每个元素都会对这个单词的定义做或多或少的贡献,所以我们会用其代替使用一 一映射的独热编码来表示单词或词组。

royaling:与皇室相关的;masculining:与男子汉气概相关的;feminining:与女子特点相关的;Age:年龄。

从图中我们可以看到,King和Queen与royaling很相关,这显而易见,所以这个维度上King和Queen的分数应该要高点,其他也是如此。

另外可以这样思考:VGueen - VWoman = [0.97 0.04 -0.069 0.1](记为Vt),这个向量表示什么意思?Vman+Vt 等于什么呢?约等于VKing吗?下面会给出答案。

Reasoning with word vectors

We find that the learned word representations in fact capture meaningful syntactic and semantic regularities in a very simple way. Specifically, the regularities are observed as constant vector offsets between pairs of words sharing a particular relationship. For example, if we denote the vector for word i as xi, and focus on the singular/plural relation, we observe that xapple – xapples ≈ xcar – xcars, xfamily – xfamilies ≈ xcar – xcars, and so on. Perhaps more surprisingly, we find that this is also the case for a variety of semantic relations, as measured by the SemEval 2012 task of measuring relation similarity.

我们发现模型学习到的词表示方法(词向量)实际上能够以一种很简单的方式表示单词对应的语法(Kings,King)和语义规律。更具体的来说,这些规律是用拥有特定关系的词对所对应的两个向量的差来表示的。例如,假设我们把单词i对应的向量记为Vi,那么对于表示单复数这个维度上的数值K来说应该有:applesk – applek ≈ carsk – cark, ≈  familiesk – familyk .可能更让人惊讶的是,我们发现在2012年的SemEval关系相似度测量任务中,各种各样的语义(语义:这个单词是什么意思)关系都可以有上述所说的性质。

The vectors are very good at answering analogy questions of the form a is to b as c is to ?. For example, man is to woman as uncle is to ? (aunt) using a simple vector offset method based on cosine distance.

这样的向量非常适合于分析“a对应b,那么c对应什么”这样的分析性问题。例如,如果男人对应女人,那么伯父应该对应什么?(伯母)

For example, here are vector offsets for three word pairs illustrating the gender relation:

如下图所示,图中用向量的差(相对偏移量)表示了三个词对之间的性别关系。

And here we see the singular plural relation:

另外还有单复数的关系:

This kind of vector composition also lets us answer “King – Man + Woman = ?” question and arrive at the result “Queen” !

上图所展示的向量有助于我们回答“国王-男人+女士=?”的问题,另外答案就是“女王”。

利用词向量进行推理(Reasoning with word vectors)的更多相关文章

  1. NLP(二十) 利用词向量实现高维词在二维空间的可视化

    准备 Alice in Wonderland数据集可用于单词抽取,结合稠密网络可实现其单词的可视化,这与编码器-解码器架构类似. 代码 from __future__ import print_fun ...

  2. NLP︱高级词向量表达(一)——GloVe(理论、相关测评结果、R&python实现、相关应用)

    有很多改进版的word2vec,但是目前还是word2vec最流行,但是Glove也有很多在提及,笔者在自己实验的时候,发现Glove也还是有很多优点以及可以深入研究对比的地方的,所以对其进行了一定的 ...

  3. NLP︱词向量经验总结(功能作用、高维可视化、R语言实现、大规模语料、延伸拓展)

    R语言由于效率问题,实现自然语言处理的分析会受到一定的影响,如何提高效率以及提升词向量的精度是在当前软件环境下,比较需要解决的问题. 笔者认为还存在的问题有: 1.如何在R语言环境下,大规模语料提高运 ...

  4. PyTorch基础——词向量(Word Vector)技术

    一.介绍 内容 将接触现代 NLP 技术的基础:词向量技术. 第一个是构建一个简单的 N-Gram 语言模型,它可以根据 N 个历史词汇预测下一个单词,从而得到每一个单词的向量表示. 第二个将接触到现 ...

  5. 词向量word2vec(图学习参考资料)

    介绍词向量word2evc概念,及CBOW和Skip-gram的算法实现. 项目链接: https://aistudio.baidu.com/aistudio/projectdetail/500940 ...

  6. 【CS224n-2019学习笔记】Lecture 1: Introduction and Word Vectors

    附上斯坦福cs224n-2019链接:https://web.stanford.edu/class/archive/cs/cs224n/cs224n.1194/ 文章目录 1.课程简单介绍 1.1 本 ...

  7. 词向量 词嵌入 word embedding

    词嵌入 word embedding embedding 嵌入 embedding: 嵌入, 在数学上表示一个映射f:x->y, 是将x所在的空间映射到y所在空间上去,并且在x空间中每一个x有y ...

  8. Word Representations 词向量

    常用的词向量方法word2vec. 一.Word2vec 1.参考资料: 1.1) 总览 https://zhuanlan.zhihu.com/p/26306795 1.2) 基础篇:  深度学习wo ...

  9. 词袋模型(BOW,bag of words)和词向量模型(Word Embedding)概念介绍

    例句: Jane wants to go to Shenzhen. Bob  wants to go to Shanghai. 一.词袋模型 将所有词语装进一个袋子里,不考虑其词法和语序的问题,即每个 ...

随机推荐

  1. canvas 实现渐变色填充的三角形

    实现效果 效果一: 效果二: 实现思路 canvas实现 1. 绘制三角形 // html <canvas id="triangle" width="30" ...

  2. IDEA版本2020.1全局MAVEN配置

    我们用IDEA打开项目有时候要每次配置maven地址,这样就很麻烦 我们可以直接设置全局的 这样所有新打开的项目都能使用

  3. js(jQuery)获取自定义data属性的值

    有时候因为需要在标签上设置自定义data属性值, <div class="col-sm-6 col-md-4" id="get_id" data-c_id ...

  4. java源码——计算不同图形的周长和面积

    计算任意三角形,正方形,正五边形,圆形的周长和面积. 利用类的继承实现. 将计算结果进行输出. 不多说,贴码. Contants.java 常量存储类 <pre name="code& ...

  5. 【LeetCode】01 Matrix 解题报告

    [LeetCode]01 Matrix 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/01-matrix/#/descripti ...

  6. 【LeetCode】223. Rectangle Area 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/rectangl ...

  7. 【LeetCode】650. 2 Keys Keyboard 只有两个键的键盘(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 素数分解 日期 题目地址:https://le ...

  8. 实战!Spring Boot 整合 阿里开源中间件 Canal 实现数据增量同步!

    大家好,我是不才陈某~ 数据同步一直是一个令人头疼的问题.在业务量小,场景不多,数据量不大的情况下我们可能会选择在项目中直接写一些定时任务手动处理数据,例如从多个表将数据查出来,再汇总处理,再插入到相 ...

  9. 『学了就忘』vim编辑器基础 — 96、末行模式中的相关命令

    目录 1.在文档中显示行号 2.是否显示文档内容相关颜色 3.是否将查找的字符串高亮显示 4.是否显示右下角的状态栏 5.是否在左下角显示如"--INSERT--"之类的状态栏 6 ...

  10. 2019HPU-ICPC-Training-1

    byl太强了,学弟们太强了-全程被吊打,嘤嘤嘤- A题  Connecting Vertices http://codeforces.com/problemset/problem/888/F 不会 B ...