利用词向量进行推理(Reasoning with word vectors)
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)的更多相关文章
- NLP(二十) 利用词向量实现高维词在二维空间的可视化
准备 Alice in Wonderland数据集可用于单词抽取,结合稠密网络可实现其单词的可视化,这与编码器-解码器架构类似. 代码 from __future__ import print_fun ...
- NLP︱高级词向量表达(一)——GloVe(理论、相关测评结果、R&python实现、相关应用)
有很多改进版的word2vec,但是目前还是word2vec最流行,但是Glove也有很多在提及,笔者在自己实验的时候,发现Glove也还是有很多优点以及可以深入研究对比的地方的,所以对其进行了一定的 ...
- NLP︱词向量经验总结(功能作用、高维可视化、R语言实现、大规模语料、延伸拓展)
R语言由于效率问题,实现自然语言处理的分析会受到一定的影响,如何提高效率以及提升词向量的精度是在当前软件环境下,比较需要解决的问题. 笔者认为还存在的问题有: 1.如何在R语言环境下,大规模语料提高运 ...
- PyTorch基础——词向量(Word Vector)技术
一.介绍 内容 将接触现代 NLP 技术的基础:词向量技术. 第一个是构建一个简单的 N-Gram 语言模型,它可以根据 N 个历史词汇预测下一个单词,从而得到每一个单词的向量表示. 第二个将接触到现 ...
- 词向量word2vec(图学习参考资料)
介绍词向量word2evc概念,及CBOW和Skip-gram的算法实现. 项目链接: https://aistudio.baidu.com/aistudio/projectdetail/500940 ...
- 【CS224n-2019学习笔记】Lecture 1: Introduction and Word Vectors
附上斯坦福cs224n-2019链接:https://web.stanford.edu/class/archive/cs/cs224n/cs224n.1194/ 文章目录 1.课程简单介绍 1.1 本 ...
- 词向量 词嵌入 word embedding
词嵌入 word embedding embedding 嵌入 embedding: 嵌入, 在数学上表示一个映射f:x->y, 是将x所在的空间映射到y所在空间上去,并且在x空间中每一个x有y ...
- Word Representations 词向量
常用的词向量方法word2vec. 一.Word2vec 1.参考资料: 1.1) 总览 https://zhuanlan.zhihu.com/p/26306795 1.2) 基础篇: 深度学习wo ...
- 词袋模型(BOW,bag of words)和词向量模型(Word Embedding)概念介绍
例句: Jane wants to go to Shenzhen. Bob wants to go to Shanghai. 一.词袋模型 将所有词语装进一个袋子里,不考虑其词法和语序的问题,即每个 ...
随机推荐
- MyBatis学习(二)MyBatis-Statement方式的增删改查
1.前期准备 项目骨架图如下所示 1.配置conf.xml <?xml version="1.0" encoding="UTF-8" ?> < ...
- java -jar 配置参数写法说明
java -Dxxx=test -jar xxx.jar (放在-jar之前) 取值:System.getProperty("xxx") spring的@value(" ...
- 痞子衡嵌入式:把玩i.MXRT1062 TencentOS Tiny EVB_AIoT开发板(2) - 在Flash调试及离线启动
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是i.MXRT1062 TencentOS Tiny EVB_AIoT开发板在Flash调试与离线启动. 腾讯 TencentOS 团队于 ...
- 【LeetCode】962. Maximum Width Ramp 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 单调栈 日期 题目地址:https://leetco ...
- P1547逆转,然后再见
描述 上届的高三在这个暑假终于要到各个城市奔向他们的大学生活了.奇怪的是学校这次异常阔气,说要用三台车子去载他们上学.上届高三的师兄们异常兴奋--可惜的是临行的时候,学校终于露出它"狰狞&q ...
- ROC and AUC
目录 概 TPR, FPR ROC and AUC 代码 ROC-wiki 概 AUC常常在文章中作为评价一个分类器优劣的指标, 却总是忘记其原由, 索性记上一笔. TPR, FPR 首先理解TP, ...
- 5分钟搭建wordpress个人博客网站——宝塔傻瓜式部署,无坑系列,附赠主题和md插件[2021-12-31]
一.前言 自从买了服务器,小编已经马不停蹄的学了两天服务搭建的知识,问了很多大佬,快速搭建自己的博客网站.有四种方式,我在这里全部分享给大家.自己已经搭建好,欢迎大家过来看一下,给你提供个思路哈! 小 ...
- AVD Pixel_2_API_30 is already running. lf that is not the case, delete the files at
AVD Pixel_2_API_30 is already running. lf that is not the case, delete the files at C:\Users\Adminis ...
- RESTful测试工具RESTClient
1.简介 RESTClient是一个用于测试RESTful Web服务的客户端, 是用Java Swing编写的基于Http协议的接口测试工具, 它可以向服务器发送各种Http请求,并显示服务器响应. ...
- 实践剖析.NET Core如何支持Cookie和JWT混合认证、授权
前言 为防止JWT Token被窃取,我们将Token置于Cookie中,但若与第三方对接,调用我方接口进行认证.授权此时仍需将Token置于请求头,通过实践并联系理论,我们继续开始整活!首先我们实现 ...