中文词嵌入 | PaperReader

举报
Tracy 发表于 2019/10/15 14:03:24 2019/10/15
【摘要】 计算机理解自然语言是个很困难的问题。第一个重要的步骤是如何将文字表达成计算机可识别的方式。通常的做法是通过数学模型进行运算把文字(词语)转化成数字或向量表示。以下我们将分别简述几种常用的数学表述方法及中文词嵌入最新的进展。1# 索引(Index) 索引是把句子中所有出现的词语提取出来建立一个词典,给每个词语赋予唯一的序号。如下例所示:[一棵,是,枣树,另,一棵,也,是,枣树] = [0, 1...

计算机理解自然语言是个很困难的问题。第一个重要的步骤是如何将文字表达成计算机可识别的方式。通常的做法是通过数学模型进行运算把文字(词语)转化成数字或向量表示。以下我们将分别简述几种常用的数学表述方法及中文词嵌入最新的进展。

1# 索引(Index) 索引是把句子中所有出现的词语提取出来建立一个词典,给每个词语赋予唯一的序号。如下例所示:

[一棵,是,枣树,另,一棵,也,是,枣树] = [0, 1, 2, 3, 0, 4, 1, 2]

由于这种序号可作为分类信号,序号之间的数值没有实际物理意义,不能直接用于运算。

2# 独热编码(One-Hot Encoding) 独热编码是将每个词语表达为一个词典长度的向量,每个词向量中对应词语序号所在的位置为数值 1,其它位置均为 0。以上文中 [一棵,是,枣树,另,一棵,也,是,枣树] 为例,该编码表达为: [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]] 这种方法虽然可以对模型进行运算,但映射出来的词向量都是两两正交,无法体现词语间的语义相关性;而且矩阵过于稀疏,在词典较大的情况下空间浪费很大。

3# 共现编码(Co-Occurence Encoding) 共现编码则是以某个词为中心,找到它左右区间的词语,根据临近词的位置定坐标,等所有词都定好坐标后再将相同项相加,得到最终坐标向量。以上文中[一棵,是,枣树,另,一棵,也,是,枣树] 以 2-gram 为例, 该编码表达为: [[0,1, 0, 0, 0], [1,0,1,0,0], [0,1,0,1,0], [1,0,1,0,0], [0,0,0,1,1], [1,0,1,0,0], [0,0,1,0,1], [0,1,0,0,0]] 由于相同意义的词周围往往容易出现相同的词,因此这种方法适用于找出词义相近的词语,同时亦考虑了词出现的次序,但它同样面临着词向量过长的问题。

此外,还有其他各种传统词语的表示法,但是大多传统的方法都会面临词典过大时带来的词向量过长、数据过于稀疏的问题。为了解决以上的问题,基于神经网络的词嵌入(word embedding)方法逐渐成为主流。

根据维基百科定义:词嵌入是自然语言处理中语言模型与表征学习技术的统称。概念上而言,它是指把一个维数为所有词的数量的高维空间嵌入到一个维数低得多的连续向量空间中,每个单词或词组被映射为实数域上的向量。

通俗来说,词嵌入就是把词典里的每一个词分别表示为一个向量,得到的向量通常称为「词向量」,好的映射可以有效抽取词语间的语义相关性。根据这个定义,实际上传统的 one-hot encoding、index 等方法也可以被称为词嵌入方法,但从狭义的角度而言,以下讨论的「词向量」一词,都是指基于神经网络训练的词嵌入方法。

词嵌入在自然语义理解领域内所有任务中都担任着最基础、最核心的功能,包括文本分类、文本摘要、信息检索、自动对话等,通过词嵌入得到好的词向量作为模型的初始参数,可以帮助几乎所有的各类 NLP 任务取得更好的效果。

一个好的「词嵌入」可以读取词语与词语之间的语义信息,同时也会避免稀疏性,节省空间。我们把词语与词语之间的语义相近程度称为相似度,举个例子: ** 高兴 = (1.00, -0.31, 0.42, -0.02, -0.23) 开心 = (0.90, -0.25, 0.45, -0.10, -0.11) 难过 = (-0.80, 0.33, -0.35, 0.04, 0.09) 天气 = (0.82, 0.21, -0.30, 0.55, 0.71)**

假设以上四个词存在于同一个五维空间内,其中「高兴」与「开心」语义较为接近,他们每个向量正负相同,在同一个区域内,并且各个维度的数值都十分接近,这种情况下可以说它的相似度高。而「高兴」与「难过」是反义词,用向量表达时正负值一般为相反,距离更远。词语「天气」与其余词没有很明显的语义相关关系,故无呈现出特殊相关规则。

以上是对于相似度定性的讨论,而一般定量地,相似度大小可以通过余弦相似度来衡量,余弦相似度可通过以下公式计算:在词嵌入领域最经典的模型是连续词袋模型(Continuous Bag Of Words, CBOW) 和跨词序列模型(Skip-gram) ,如下图所示是它们的结构模型。这两个是由 Tomas Mikolov 等人 2013 年在论文《Efficient Estimation of Word Representations in Vector Space》中提出的。

如图所示,CBOW 是通过周围的词 w(t-2),w(t-1),w(t+1),w(t+2) 预测中间的词 w(t),它会给所有词赋予一个随机的长度向量,接着将周围的词 w(t-2),w(t-1),w(t+1),w(t+2) 输入线性模型内做非线性变换,通过 softmax 概率预测 w(t)。而 Skip-gram 是通过中间的词 w(t)预测周围的词 w(t-2),w(t-1),w(t+1),w(t+2) ,最大化对 w(t-2),w(t-1),w(t+1),w(t+2)的预测之和。

CBOW 和 skip-gram 模型在预测的过程中,不断迭代更新最初随机分配给每个词语的向量。待训练收敛后,最终的向量即为训练所的的「词向量」。

中文词嵌入

不同语言体系需要训练的词向量亦不相同,近年来一些学者开始研究针对中文词嵌入的训练方式。中文词嵌入是否训练的好的效果评价标准主要有以下几种:

1# 词语相似性 数据集:wordsim240/wordsim296 该数据集包含一系列词语对,计算训练好词向量之后计算各词语对的相似度,求相似度与人工打分相关系数 ρ 。

2# 词语推理

数据集:CWE 自建数据集 该数据集包括家庭信息、地理信息等 1125 条推理类数据,如「巴黎:法国==罗马:?」,通过计算词语推理的准确率来评价效果。

3# 分类任务 数据集:复旦语料(Fudan Corpus)等 该数据集包含 9804 篇共 20 类文章,文章类型包括环境、农业、经济、政治等。以预训练的词向量作为输入,训练文本分类模型,最终准确率为度量。

4# 个案研究 根据对模型特点的认知与思考,提取部分典型的、具有代表性的词语个例,观察其最邻近的相关词语等。

接下来通过 7 篇代表最新技术进展的论文来直面感受中文词嵌入的发展。

*公众号后台回复「中文词嵌入」,获取以下论文下载地址。公众号后台回复「中文词嵌入」,获取以下论文下载地址。公众号后台回复「中文词嵌入」,获取以下论文下载地址。

1# Joint Learning of Character and Word Embeddings(IJCAI 2015)1# Joint Learning of Character and Word Embeddings(IJCAI 2015)

Xinxiong Chen, Lei Xu, Zhiyuan Liu, Maosong Sun, Huanbo Luan

**亮点:**字符粒度的中文词向量训练& 变种—考虑字符在词语中出现的区域

**摘要:**Most word embedding methods take a word as a basic unit and learn embeddings according to words’ external contexts, ignoring the internal structures of words. However, in some languages such as Chinese, a word is usually composed of several characters and contains rich internal information. The semantic meaning of a word is also related to the meanings of its composing characters. Hence, we take Chinese for example, and present a character enhanced word embedding model (CWE). In order to address the issues of character ambiguity and non-compositional words, we propose multiple prototype character embeddings and an effective word selection method. We evaluate the effectiveness of CWE on word relatedness computation and analogical reasoning. The results show that CWE outperforms other baseline methods which ignore internal character information. The codes and data can be accessed from https://github.com/Leonard-Xu/CWE.**笔记:**此文为中文词嵌入领域最早使用文字级别颗粒度进行训练的文章。文章将词语拆分为文字的组合,通过 CBOW 进行训练,非常符合直观思路。除了基本的 character embeddings 以外,文章还提出了基于此的几项扩展:position-based character embeddings、cluster-based character embeddings、nonparametric clustrer-based character embeddings。其中 position-based character embeddings 对每一个字符给予三个带训练 vectors,分别是该字符属于词语开头时、该字符属于词语中间时、该字符属于词语末尾时;cluster-based character embeddings 则对每个字符出现的上下文场景(如一同构成词语的其它字)进行聚类,当聚类中心选为 N(c)个时,这个字符将有 N(c)种向量表示。在实验中对比原版 character embeddings 时,文章报告的数据显示 position-based 的变种比原版较好。

2# Multi-Granularity Chinese Word Embedding(EMNLP 2016)

Rongchao Yin, Quan Wang, Rui Li, Peng Li, Bin Wang **亮点:**将偏旁部首粒度也纳入到 embeddings 的范围。 **摘要:**This paper considers the problem of learning Chinese word embeddings. In contrast to English, a Chinese word is usually composed of characters, and most of the characters themselves can be further divided into components such as radicals. While characters and radicals contain rich information and are capable of indicating semantic meanings of words, they have not been fully exploited by existing word embedding methods. In this work, we propose multi-granularity embedding (MGE) for Chinese words. The key idea is to make full use of such word-character-radical composition, and enrich word embeddings by further incorporating finer-grained semantics from characters and radicals. Quantitative evaluation demonstrates the superiority of MGE in word similarity computation and analogical reasoning.Qualitative analysis further shows its capability to identify finer-grained semantic meanings of words.**笔记:**标题中的「多尺度」,在文章中表现为,除了输入上下文词语、上下文词语字符外,还输入了预测词语的偏旁部首(radicals)。偏旁部首在汉字中有一定的表义能力,显式地对偏旁部首进行编码增强了模型所能提取到的信息。

3# Joint Embeddings of Chinese Words, Characters, and Fine-grained Subcharacter Components(EMNLP 2017)

Jinxing Yu, Xun Jian, Hao Xin, Yangqiu Song **亮点:**拆分文字,将子字符信息纳入到训练中。

**摘要:**Word embeddings have attracted much attention recently. Different from alphabetic writing systems, Chinese characters are often composed of subcharacter components which are also semantically http://informative.In this work, we propose an approach to jointly embed Chinese words as well as their characters and fine-grained subcharacter components. We use three likelihoods to evaluate whether the context words, characters, and components can predict the current target word, and collected 13,253 subcharacter components to demonstrate the existing approaches of decomposing Chinese characters are not enough. Evaluation on both word similarity and word analogy tasks demonstrates the superior performance of our model.

**笔记:**JWE 主要是扩展了 MGE,文章认为 MGE 在子字符粒度仅使用偏旁部首的方式,依然遗漏了较多的文字构成信息。故 JWE 不仅保留了文字的偏旁部首,还将每一个汉字拆分成多个最小汉字的组合并进行训练,这就是标题所提及的「fine-grained subcharacter components」。

4# Improve Chinese Word Embeddings by Exploiting Internal Structure(HLT-NAACL 2016)

Jian Xu, Jiawei Liu, Liangang Zhang, Zhengyu Li, Huanhuan Chen

**亮点:**通过引入语义相似性,文章非常有效地解决了纯粹使用文字粒度训练带来的噪音。

**摘要:**Recently, researchers have demonstrated that both Chinese word and its component characters provide rich semantic information when learning Chinese word embeddings. However, they ignored the semantic similarity across component characters in a word. In this paper, we learn the semantic contribution of characters to a word by exploiting the similarity between a word and its component characters with the semantic knowledge obtained from other languages. We propose a similarity-based method to learn Chinese word and character embeddings jointly. This method is also capable of disambiguating Chinese characters and distinguishing non-compositional Chinese words. Experiments on word similarity and text classification demonstrate the effectiveness of our method.**笔记:**个人认为此文是前后各文中最有价值和说服力的一篇。对比 CWE 和 CBOW 对某特定词语的最邻近词,可以发现由于 CWE 使用了文字编码,故其具有很强的倾向将使用了同样字的词语找出来,即使该词的语义相关性低/日常使用频率低。SCWE 指出了 CWE 中存在的问题:

1.汉语中一个文字往往有繁多的含义,故不考虑语义差异,纯粹使用字符编码会产生较多生搬硬套的情况,虽然 CWE 中有扩展唯一 char embeddings 的 position-based、cluster-based 等变种,但是并没有显式地对语义进行归类提取。

2.词语和组成词语的字,实际上可能存在不一样的含义,或每个字对于词语表义的权重并不一致,如「妻子」中的「子」字,一般认为与原词意义相差较远,「青蛙」中的「蛙」字比「青」字对词语表义的权重更大等。

SCWE 使用了以下几个步骤,显式地将文字语义添加入训练过程中:

1.对每一个汉字、词语,使用金山词霸进行汉英翻译,得到多项英文释义;

2.合并字义项:训练一个英文的 word embeddings,并对每一个汉字的各项英文释义两两进行相似度比对,当小于某阈值时,将该汉字的此两项释义。合并合并完成后,某汉字剩余的释义项数即为该字的 char vector 数量,并进行编号;

3.对于每一个词 w,假设其由 n 个汉字(c1, c2, ...)组成,则将该词的英文释义与每个组成汉字的每个释义进行相似度计算,最后保留每个相似度的最大值(s1, s2, ...)和取到最大值时对应的字符释义 index(n1, n2, ...);

4.使用(s1, s2, ...)相似度添加对应字并训练模型,得到 char vectors 和初步的 word vectors。

5# Learning Chinese Word Representations From Glyphs Of Characters(EMNLP 2017)

Tzu-Ray Su, Hung-Yi Lee **亮点:**采用文字的图像压缩特征进入训练 **摘要:**In this paper, we propose new methods to learn Chinese word representations. Chinese characters are composed of graphical components, which carry rich semantics. It is common for a Chinese learner to comprehend the meaning of a word from these graphical components. As a result, we propose models that enhance word representations by character glyphs. The character glyph features are directly learned from the bitmaps of characters by convolutional auto-encoder(convAE), and the glyph features improve Chinese word representations which are already enhanced by character embeddings. Another contribution in this paper is that we created several evaluation datasets in traditional Chinese and made them public.

**笔记:**文章认为作为象形文字,汉字的图像信息也包含了一定量的语义信息,比起手动切分子模块/偏旁部首,可以直接采用整个字符的图像提取特征。故文章采用(60pixels * 60pixels)的楷体繁体字,训练了一个 5 层 encoder、5 层 decoder 的 CNN autoencoder,将每个字的图像信息压缩为一个 512 维的向量进行训练。然而最终文章的测试数据显示,GWE 并没有表现出比原版 CWE 甚至是 CBOW 显著更优,且其模型会因图像的相似产生部分反语义的误差(如,GWE 中词语「山峰」和「蜂蜜」的语义相关度比其它模型都要高)。

6# cw2vec: Learning Chinese Word Embeddings with Stroke n-gram Information(AAAI 2018)

Shaosheng Cao, Wei Lu, Jun Zhou, Xiaolong Li

**亮点:**使用笔画粒度的信息进行训练。 **摘要:**We propose cw2vec, a novel method for learning Chinese word embeddings. It is based on our observation that exploiting stroke-level information is crucial for improving the learning of Chinese word embeddings. Specifically, we design a minimalist approach to exploit such features, by using stroke n-grams, which capture semantic and morphological level information of Chinese words. Through qualitative analysis, we demonstrate that our model is able to extract semantic information that cannot be captured by existing methods. Empirical results on the word similarity, word analogy, text classification and named entity recognition tasks show that the proposed approach consistently outperforms state-of-the-art approaches such as word-based word2vec and GloVe, character-based CWE, component-based JWE and pixel-based GWE.

**笔记:**文章先将汉字拆分成按笔画(strokes)顺序编码的序列,其中笔画共分为五类(横、竖、撇、捺、折),然后取一定长度的 stroke n-grams(文章中使用 3 ~ 12)作为特征,采用 skip-gram 的方式进行训练。文章使用下图左简单说明了使用笔画编码的动机:ridical-based 的 MGE 在拆分文字时只提取了部分信息;component-based 的 JWE 在拆分文字时将文字拆分为最细的粒度,但细粒度的子字符与原字符的语义间很可能不是很好的组成关系;stroke-based 的方法,如果按作者的预想,可以智能地提取合适的子字符区域,潜在中使得子区域的语义匹配更加准确。

7# A Hybrid Learning Scheme for Chinese Word Embedding

Wenfan Chen, Weiguo Sheng

**亮点:**混合了 compositional 和 predictive 方法,用两种模型结构共同训练。 **摘要:**To improve word embedding, subword information has been widely employed in state-of-the-art methods. These methods can be classified to either compositional or predictive models. In this paper, we propose a hybrid learning scheme, which integrates compositional and predictive model for word embedding. Such a scheme can take advantage of both models, thus effectively learning word embedding. The proposed scheme has been applied to learn word representation on Chinese. Our results show that the proposed scheme can significantly improve the performance of word embedding in terms of analogical reasoning and is robust to the size of training data.

**笔记:**文章提出此前对中文的多种 word embeddings 方法主要可以分为两类:compositional 和 predictive,作者对其的解释为,predictive 的模型使用多个分离的信息向量来预测目标词语;而 compositional 的模型将所有的信息通过各种方式组合成一个向量然后预测目标词语。而文章标题「Hybrid」意味着,模型同时使用了 compositional 和 predictive 两种模型进行训练并得到结果,其中 predictive 的模型如图 1 所示,其组成与文章 JWE 基本一样;predictive 的模型如下图 2,根据作者的解释,白色圆点为 h1、h2...、h5 的平均值点,然后再与黑色圆点即目标词点作 loss 计算。然而在这种结构下,个人认为所谓的 compositional 和 predictive 模型并没有本质差异,或者可以认为 compositional 模型是 predictive 模型的一个特例。文章最终提供的数据指标也并没有普遍的提升,个人认为不存在特别强的说服力。

总结

通过以上几篇论文可以看出中文词嵌入主要分为基于形态和基于语义两个方向。

基于形态的方法通过深入挖掘汉字的形态构成特征,将中文词语拆分成字符、偏旁部首、子字符、笔画等等细分的特征,这些特征与原词语一并进入词嵌入模型,给模型提供更多的语义信息。

基于语义的方法显式地对中文字符层级语义多样性进行建模,可以有效处理一字多义的问题,更能通过字词语义相似性的先验,非平均地对待构成词的不同字符。

从发展及改进的角度看,基于形态的方法引入特征信息的同时也会引入一定的噪音,因此模型可能产生对噪音的过拟合(如经 CWE 训练后,某个词语的最近似词非常倾向于出现在使用过同样字的词语中)。使用过细的特征可能会存在表义能力渐弱、噪音增加的问题,在元素拆分几乎达到极致的情况下,如何适当地选择特征层级、设计去噪方法以提高信噪比等方向值得思考。至于基于语义的方法,观察到在 SCWE 中,英翻辅助的处理方式有助于在训练前得到字义、词义的基点并提供给模型,但该方法也同时存在字词相似度信息不可变、新词翻译难处理等不足,有待于探索更多的处理方案。


本文转载自异步社区。

文链接:

https://www.epubit.com/articleDetails?id=Nfb153e13-1ff1-4b19-8835-16d23541a3b8

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200