跨语言词向量笔记4. 句级别对齐方法

跨语言词向量笔记4. 句级别对齐方法

    • 使用平行语料的句子级别方法
      • 组成法
      • 双语自编码器
      • 双语skip-gram
      • 其它方法
    • 使用可比较数据的句级别对齐方法
    • 参考文献

本文完全来自于Anders Søgaard等人的著作[Søgaard2019] Søgaard, A., Vulić, I., Ruder, S., & Faruqui M. (2019). Cross-Lingual Word Embeddings

使用平行语料的句子级别方法

使用句子对齐数据的方法基本上都是成功的单语模型的扩展,可以大致分为三类

组成法

组成法由[Hermann2013]引入,思想是将词向量组合成句向量,然后训练模型让平行句各自的向量互相靠近。对于平行句 s e n t s {sent}^s sents s e n t t {sent}^t sentt,语言 s s s的句子 s e n t s {sent}^s sents对应的向量 y s \boldsymbol{y}^s ys由组成它的词的词向量相加而得
y s = ∑ i = 1 ∣ s e n t s ∣ x i s \boldsymbol{y}^s = \sum_{i=1}^{|sent^s|}\boldsymbol{x}_i^s ys=i=1sentsxis

训练的目标是最小化已对齐句对 s e n t s sent^s sents s e n t t sent^t sentt之间的距离

E d i s t ( s e n t s , s e n t t ) = ∥ y s − y t ∥ 2 E_{\rm dist}(sent^s, sent^t) = \|\boldsymbol{y}^s - \boldsymbol{y}^t\|^2 Edist(sents,sentt)=ysyt2

优化的目标函数是MMHL(Max Margin Hinge Loss),让源句与已对齐目标句之间的距离,比其与随机抽出的负样本之间的距离更近
Ω M M H L = ∑ ( s e n t s , s e n t t ) ∈ C ∑ i = 1 k max ⁡ ( 0 , 1 + E d i s t ( s e n t s , s e n t t ) − E d i s t ( s e n t s , s i t ) ) \Omega_{\rm MMHL} = \sum_{(sent^s, sent^t) \in \mathcal{C}}\sum_{i=1}^k \max\left(0, 1 + E_{\rm dist}(sent^s, sent^t) - E_{\rm dist}(sent^s, s_i^t)\right) ΩMMHL=(sents,sentt)Ci=1kmax(0,1+Edist(sents,sentt)Edist(sents,sit))
其中 k k k是负样本数量。此外,对每个语言,施加一个 ℓ 2 \ell_2 2正则项 Ω ℓ 2 = λ / 2 ∥ X ∥ 2 \Omega_{\ell_2} = \lambda / 2 \|\boldsymbol{X}\|^2 Ω2=λ/2X2。因此最终总损失函数为
J = Ω ℓ 2 ( X s ) + Ω ℓ 2 ( X t ) + Ω M M H L ( X s , X t , C ) J = \Omega_{\ell_2}(\boldsymbol{X}^s) + \Omega_{\ell_2}(\boldsymbol{X}^t) + \Omega_{\rm MMHL}(\boldsymbol{X}^s, \boldsymbol{X}^t, \mathcal{C}) J=Ω2(Xs)+Ω2(Xt)+ΩMMHL(Xs,Xt,C)
这里所有损失函数都是一起优化,没有特别独立设计的单语目标函数。[Soyer2015]将其做了些扩展,用到了短语级的单语目标函数

双语自编码器

[Lauly2013]的做法是尝试根据原始句子重构目标句。他们也是把句子编码成词向量之和,然后使用语言相关的编码器-解码器和分层softmax来训练自编码器,重构句子本身和对应的翻译。在这种情况下,编码器参数是词嵌入矩阵 X s \boldsymbol{X}^s Xs X t \boldsymbol{X}^t Xt,解码器参数是将已编码信息投影到输出语言空间的矩阵。目标函数为
J = L A U T O s → s + L A U T O t → t + L A U T O s → t + L A U T O t → s J = \mathcal{L}_{\rm AUTO}^{s\rightarrow s} + \mathcal{L}_{\rm AUTO}^{t\rightarrow t} + \mathcal{L}_{\rm AUTO}^{s\rightarrow t} + \mathcal{L}_{\rm AUTO}^{t\rightarrow s} J=LAUTOss+LAUTOtt+LAUTOst+LAUTOts
其中 L A U T O s → t \mathcal{L}_{\rm AUTO}^{s \rightarrow t} LAUTOst是从源语言 s s s句子重构为目标语言 t t t句子的损失函数。对齐句子对是从平行语料中抽样获得,所有损失函数一起优化。该小组的后续扩展[Chandar2014]是使用二元词袋来代替分层softmax。由于引入词袋以后维度变高模型变复杂,该方法提出将一个mini batch中的所有词袋融合成一个词袋,在这个融合词袋上更新。此外,还在目标函数上加了一项,通过对两个向量所有维度的相关性标量求和,来提高源句和目标句向量之间的相关性(书上就写得比较简单,可能需要读引用的原文)

双语skip-gram

一些方法是对单语的SGNS模型进行扩展来学习跨语言词向量,做法都是将两种语言的单语SGNS损失值和一个额外的跨语言正则项一起联合优化,形如
J = L S G N S s + L S G N S t + Ω ( X s , X t , C ) J = \mathcal{L}_{\rm SGNS}^s + \mathcal{L}_{\rm SGNS}^t + \Omega(\boldsymbol{X}^s, \boldsymbol{X}^t, \mathcal{C}) J=LSGNSs+LSGNSt+Ω(Xs,Xt,C)
而且这些工作都没用到已对齐句的词对齐信息,只是对数据对齐做了不同假设

BilBOWA(Bilingual Bag-of-Words without Word Alignments)[Gouws2015]假设源句中的每个单词都与目标句的每个单词对齐。很显然,知道对齐信息的情况下,一个自然的想法是让对齐的单词词向量尽量接近。那么如果任意源句单词都与所有目标句单词对齐,实际上也就是让它们词向量的均值尽量接近,即BilBOWA的目标函数是
y s = 1 ∣ s e n t s ∣ ∑ i = 1 ∣ s e n t s ∣ x i s Ω B i l B O W A = ∑ ( s e n t s , s e n t t ) ∈ C ∥ y s − y t ∥ 2 \begin{aligned} \boldsymbol{y}^s &= \frac{1}{|sent^s|}\sum_{i=1}^{|sent^s|}\boldsymbol{x}_i^s \\ \Omega_{\rm BilBOWA} &= \sum_{(sent^s, sent^t) \in \mathcal{C}} \|\boldsymbol{y}^s - \boldsymbol{y}^t\|^2 \end{aligned} ysΩBilBOWA=sents1i=1sentsxis=(sents,sentt)Cysyt2

这个正则项很像组成法用的目标函数,唯一不同是BilBOWA用了均值,而组成法用了总和

Trans-gram[Coulmance2015]对对齐关系做了和BilBOWA相同的假设,不过在跨语言正则项用的也是SGNS目标函数,此时中心词是被对齐的目标语言单词,上下文单词来自于源语言。由于前面的对齐假设,实际上是要使用源句每个单词预测目标句子所有语言,即
Ω T r a n s − g r a m = : Ω S G N S s → t = − ∑ ( s e n t s , s e n t t ) ∈ C 1 ∣ s e n t s ∣ ∑ t = 1 ∣ s e n t s ∣ ∑ j = 1 ∣ s e n t t ∣ log ⁡ P ( w t + j ∣ w t ) \Omega_{\rm Trans-gram}=: \Omega_{\rm SGNS}^{s \rightarrow t} = -\sum_{(sent^s,sent^t)\in \mathcal{C}}\frac{1}{|sent^s|}\sum_{t=1}^{|sent^s|}\sum_{j=1}^{|sent^t|}\log P(w_{t+j}|w_t) ΩTransgram=:ΩSGNSst=(sents,sentt)Csents1t=1sentsj=1senttlogP(wt+jwt)

其中 P ( w t + j ∣ w t ) P(w_{t+j}|w_t) P(wt+jwt)使用负采样法计算

BiSkip[Luong2015]使用了和Trans-gram一样的目标函数,不过对源句中的第 i i i个词,其只用来预测目标句的第 i ⋅ s e n t t s e n t s i\cdot \frac{sent^t}{sent^s} isentssentt个词,即文章认为平行句的单词是顺序对应的

其它方法

[Levy2017]通过使用平行语料中对齐句对的ID作为特征就达到了一个不错的基线模型(这篇文章感觉太神奇了,可能需要单独看看)

使用可比较数据的句级别对齐方法

和词级别方法类似,这样的工作也是使用同一张图片的不同语言标注。不赘述

参考文献

  • [Hermann2013]: Karl Moritz Hermann and Phil Blunsom. 2013. Multilingual distributed representations without word alignment. In Proc. of the International Conference on Learning Representations (Conference Track) (ICLR 2013).
  • [Soyer2015]: Hubert Soyer, Pontus Stenetorp, and Akiko Aizawa. 2015. Leveraging monolingual data for crosslingual compositional word representations. In Proc. of the 3rd International Conference on Learning Representations (ICLR 2015).
  • [Lauly2013]: Stanislas Lauly, Alex Boulanger, and Hugo Larochelle. 2013. Learning multilingual word representations using a bag-of-words autoencoder. In arXiv preprint arXiv:1401.1803.
  • [Chandar2014]: Sarath Chandar, Stanislas Lauly, Hugo Larochelle, Mitesh M. Khapra, Balaraman Ravindran, Vikas Raykar, and Amrita Saha. 2014. An autoencoder approach to learning bilingual word representations. In Proc. of the 27th Annual Conference on Neural Information Processing Systems (NeurIPS 2014), pages 1853–1861.
  • [Gouws2015]: Stephan Gouws, Yoshua Bengio, and Greg Corrado. 2015. BilBOWA: Fast bilingual distributed representations without word alignments. In Proc. of International Conference on Machine Learning (ICML 2015).
  • [Coulmance2015]: Jocelyn Coulmance, Jean-Marc Marty, Guillaume Wenzek, and Amine Benhalloum. 2015. Trans-gram, fast cross-lingual word-embeddings. In Proc. of the Conference on Empirical Methods in Natural Language Processing (EMNLP 2015), pages 1109–1113.
  • [Luong2015]: Minh-Tang Luong, Hieu Pham, and Christopher D. Manning. 2015. Bilingual word representations with monolingual quality in mind. In Proc. of the 1st Workshop on Vector Space Modeling for Natural Language Processing, pages 151–159.
  • [Levy2017]: Omer Levy, Anders Søgaard, and Yoav Goldberg. 2017. A strong baseline for learning crosslingual word embeddings from sentence alignments. In Proc. of the 15th Conference of the European Chapter of the Association for Computational Linguistics (Volume 1: Long Papers) (EACL 2017).

你可能感兴趣的:(神经翻译笔记)