LEA: Improving Sentence Similarity Robustness to Typos Using Lexical Attention Bias 论文阅读

KDD 2023 原文地址

Introduction

文本噪声,如笔误(Typos), 拼写错误(Misspelling)和缩写(abbreviations), 会影响基于 Transformer 的模型. 主要表现在两个方面:

  1. Transformer 的架构中不使用字符信息.
  2. 由噪声引起的词元分布偏移使得相同概念的词元更加难以关联.

先前解决噪声问题的工作主要依赖于数据增强策略, 主要通过在训练集中加入类似的 typos 和 misspelling 进行训练.

数据增强确实使得模型在损坏(噪声)样本上表现出出更高的鲁棒性.

虽然这种策略在一定程度上已被证明有效地缓解了词元分布偏移的问题, 但所有这些方法仍然受到在 词元化(tokenization)中字符信息会丢失的限制.

Approach

在自注意机制中加入词感知注意模块(Lexical-aware Attention module, LEA)

自注意力(self-attention)

定义 self-attention 的输入为 \(X=\set{x_1, x_2, \dots, x_n}\), 输出为 \(Z=\set{z_1, z_2, \dots, z_n}\), 输出中的每个 token 的表示计算如下:

\[\begin{equation}
z_i=\sum_{j=i}^na_{ij}\left(x_j\cdot W^V\right), \quad z_i\in \mathbb R^{d_h}.
\end{equation}
\]

其中的注意力权重 \(a_{ij}\) 计算如下:

\[\begin{equation}
a_{ij}=\frac{\text{exp}(e_{ij})}{\sum_{k=1}^{n}\text{exp}(e_{ik})},
\end{equation}
\]

其中

\[\begin{equation}
e_{ij}=\frac{(x_iW^Q)(x_jW^K)}{\sqrt{d_h}}.
\end{equation}
\]

词注意力偏向(Lexical attention bias)

对于语义文本相似性(textual similarity), 将两个句子拼接:

\[\begin{equation}
X_c=X_l|X_r
\end{equation}
\]

主要做法是参考了相对位置嵌入(relative position embeddings)的做法, 对 self-attention 中的 \(e_{ij}\) 进行如下修改:

\[\begin{equation}
\tilde e_{ij}=e_{ij}+\alpha l_{ij} W^L,
\end{equation}
\]

其中第二项就是词偏向(lexical bias). \(W^L\in \mathbb R^{d^L\times 1}\) 是可训练参数, \(l\in \mathbb R^{1\times d^L}\) 是成对词汇注意嵌入(pairwise lexical attention embedding), \(\alpha\) 是一个固定的比例因子, 它在训练开始时根据两个项的大小自动计算一次.

为了计算成对词汇注意嵌入(pairwise lexical attention embedding), 先计算句子对之间单词的相似度, 而句子内单词的相似度设定为0:

\[\begin{equation}
s_{ij}=
\left\{
\begin{aligned}
&0 &&,\text{ if }x_i,x_j\in X_l\text{ or }x_i,x_j\in X_r\\
&\text{Sim}\big(w(x_i), w(x_j)\big) &&\text{, otherwise.}
\end{aligned}
\right.
\end{equation}
\]

其中 Sim 是一个度量, 用于表示两个单词之间的字符串相似度.

实现细节(Implementation details)

论文中相似度度量选取的是 Jaccard 系数.

只在架构的后半层添加了 lexical attention bias.

之后通过将将 \(s_{ij}\) 带入 Transformer 中的正余弦函数, 得到表示词相似度的 embedding:

\[\begin{equation}
\begin{aligned}
l_{ij}^{(s_{ij}, 2p)}&=&&\sin{\left(\frac{2\pi\cdot d_{ij}}{\beta^{2p/d_h}} \right)},\\
l_{ij}^{(s_{ij}, 2p+1)}&=&&\cos{\left(\frac{2\pi\cdot d_{ij}}{\beta^{2p/d_h}} \right)},
\end{aligned}
\end{equation}
\]

最终的词相似度嵌入 \(l_{ij}\) 是上了两个向量的拼接.

实验(Experiment)

性能(Performance)

词相似度选择的影响(Impact of the lexical similarity choice)

分析了使用不同相似度度量在 Abt-Buy 这个数据集上, BERT-Medium 的表现.

相似度度量包括: Jaccard (Jac.), Smith-Waterman (Smith), Longest Common Subsequence (LCS), Levenshtein (Lev.) and Jaro–Winkler (Jaro)

Jaccard 相似度系数是顺序不可知的, 因此对字符交换更健壮.

Jaccard 在有错别字和没有错别字的单词对之间提供了更高的可分离性, 这在短文本中是有益的.

然而, 随着句子长度的增加, 被比较的单词具有相似字符但含义不同的概率增加, 这降低了交换不变性优势.

不同层添加 LEA 与共享策略(LEA on different layers and sharing strategy)

文中认为, LEA 提供的字符级相似性可以被视为一种高级交互信息.

因此, 它为深层 Transformer 层补充了高层次的特性.

文中并没有验证这一假设.

影响噪声强度(Impact of the noise strength)

直观地说, 由于 LEA 利用的字符级相似性不是在训练过程中学习到的, 因此它们为模型提供的信息在某种程度上较少依赖于噪声的量.

图3(下)显示了随着 typos 数量的增加, LEA 的性能与普通数据增强模型之间的差距越来越大, 这表明 LEA 可以更好地泛化到不同的噪声强度.

补充实验(Additional experiments)

更大的模型(Larger model)

BERT-Large

GPT-like models

更大的数据集(Larger dataset)

BERT-M + DA 在 WDC-Comp.XL 性能超过了 LEA, 但是标准差较大.

LEA: Improving Sentence Similarity Robustness to Typos Using Lexical Attention Bias 论文阅读的更多相关文章

  1. [LeetCode] Sentence Similarity II 句子相似度之二

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...

  2. 翻译 | Improving Distributional Similarity with Lessons Learned from Word Embeddings

    翻译 | Improving Distributional Similarity with Lessons Learned from Word Embeddings 叶娜老师说:"读懂论文的 ...

  3. 734. Sentence Similarity 有字典数组的相似句子

    [抄题]: Given two sentences words1, words2 (each represented as an array of strings), and a list of si ...

  4. [LeetCode] 737. Sentence Similarity II 句子相似度之二

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...

  5. LeetCode 734. Sentence Similarity

    原题链接在这里:https://leetcode.com/problems/sentence-similarity/ 题目: Given two sentences words1, words2 (e ...

  6. [LeetCode] 737. Sentence Similarity II 句子相似度 II

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...

  7. [LeetCode] 734. Sentence Similarity 句子相似度

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...

  8. Comparing Sentence Similarity Methods

    Reference:Comparing Sentence Similarity Methods,知乎.

  9. 论文阅读笔记: Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks

    论文概况 Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks是处理比较两个句子相似度的问题, ...

  10. Distributed Sentence Similarity Base on Word Mover's Distance

    Algorithm: Refrence from one ICML15 paper: Word Mover's Distance. 1. First use Google's word2vec too ...

随机推荐

  1. Spring自定义参数解析器设计

    作者:京东零售 王鹏超 1.什么是参数解析器 @RequstBody.@RequstParam 这些注解是不是很熟悉? 我们在开发Controller接口时经常会用到此类参数注解,那这些注解的作用是什 ...

  2. STL大全

    排序最速传说--sort 我们都学过一些排序的写法,比如冒泡排序,快速排序之类的东西,举个例子来说吧,这是快速排序的代码: #include<iostream> using namespa ...

  3. 「学习笔记」AC 自动机

    「学习笔记」AC 自动机 点击查看目录 目录 「学习笔记」AC 自动机 算法 问题 思路 代码 例题 Keywords Search 玄武密码 单词 病毒 最短母串 文本生成器 背单词 密码 禁忌 前 ...

  4. Vue2积分商城项目

    一.清空项目非必要文件和用户片段,路径提示的配置 views 下面的文件只保留 Home.vue ,其余删除,删除 components/HelloWorld.vue,并且 Home.vue 中不再引 ...

  5. 2022-11-01:给定一个只由小写字母和数字字符组成的字符串str。 要求子串必须只含有一个小写字母,数字字符数量随意。 求这样的子串最大长度是多少?

    2022-11-01:给定一个只由小写字母和数字字符组成的字符串str. 要求子串必须只含有一个小写字母,数字字符数量随意. 求这样的子串最大长度是多少? 答案2022-11-01: 经典的滑动窗口问 ...

  6. 2021-01-08:cpu和gpu有什么区别?

    福哥答案2021-01-08:[答案来自此链接:](https://www.cnblogs.com/biglucky/p/4223565.html)Cache, local memory: CPU & ...

  7. 2021-06-18:已知数组arr,生成一个数组out,out的每个元素必须大于等于1,当arr[cur]>arr[cur-1]时,out[cur]>out[cur-1];当arr[cur]>arr

    2021-06-18:已知数组arr,生成一个数组out,out的每个元素必须大于等于1,当arr[cur]>arr[cur-1]时,out[cur]>out[cur-1]:当arr[cu ...

  8. Pyhton F字符串引起的invalid syntax

    事发现场 偶然运行到之前写的爬虫,发现运行不了,报错invalid syntax,于是来找bug 报错截图: 原因: 这样用法称之为 f-string f-string,亦称为格式化字符串常量(for ...

  9. 关于SpringBoot AutoConfiguration

    (1)如何导入的自动配置类 首先我们得从@SpringBootApplication注解入手. @SpringBootApplication public class SpringBootDemoAp ...

  10. AcWing 1022. 宠物小精灵之收服

    宠物小精灵是一部讲述小智和他的搭档皮卡丘一起冒险的故事. 一天,小智和皮卡丘来到了小精灵狩猎场,里面有很多珍贵的野生宠物小精灵. 小智也想收服其中的一些小精灵. 然而,野生的小精灵并不那么容易被收服. ...