LEA: Improving Sentence Similarity Robustness to Typos Using Lexical Attention Bias 论文阅读
LEA: Improving Sentence Similarity Robustness to Typos Using Lexical Attention Bias 论文阅读
KDD 2023 原文地址
Introduction
文本噪声,如笔误(Typos), 拼写错误(Misspelling)和缩写(abbreviations), 会影响基于 Transformer 的模型. 主要表现在两个方面:
- Transformer 的架构中不使用字符信息.
- 由噪声引起的词元分布偏移使得相同概念的词元更加难以关联.
先前解决噪声问题的工作主要依赖于数据增强策略, 主要通过在训练集中加入类似的 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 的表示计算如下:
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}\) 计算如下:
a_{ij}=\frac{\text{exp}(e_{ij})}{\sum_{k=1}^{n}\text{exp}(e_{ik})},
\end{equation}
\]
其中
e_{ij}=\frac{(x_iW^Q)(x_jW^K)}{\sqrt{d_h}}.
\end{equation}
\]
词注意力偏向(Lexical attention bias)
对于语义文本相似性(textual similarity), 将两个句子拼接:
X_c=X_l|X_r
\end{equation}
\]
主要做法是参考了相对位置嵌入(relative position embeddings)的做法, 对 self-attention 中的 \(e_{ij}\) 进行如下修改:
\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:
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{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 论文阅读的更多相关文章
- [LeetCode] Sentence Similarity II 句子相似度之二
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- 翻译 | Improving Distributional Similarity with Lessons Learned from Word Embeddings
翻译 | Improving Distributional Similarity with Lessons Learned from Word Embeddings 叶娜老师说:"读懂论文的 ...
- 734. Sentence Similarity 有字典数组的相似句子
[抄题]: Given two sentences words1, words2 (each represented as an array of strings), and a list of si ...
- [LeetCode] 737. Sentence Similarity II 句子相似度之二
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- LeetCode 734. Sentence Similarity
原题链接在这里:https://leetcode.com/problems/sentence-similarity/ 题目: Given two sentences words1, words2 (e ...
- [LeetCode] 737. Sentence Similarity II 句子相似度 II
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- [LeetCode] 734. Sentence Similarity 句子相似度
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- Comparing Sentence Similarity Methods
Reference:Comparing Sentence Similarity Methods,知乎.
- 论文阅读笔记: Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks
论文概况 Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks是处理比较两个句子相似度的问题, ...
- 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 ...
随机推荐
- yiiADU
<span style="font-size:14px;">一. //1.该方法是根据一个条件查询一个集合 $admin=Admin::model()->find ...
- MySQL(十一)索引的分类和创建原则
索引的创建与设计原则 1 索引的声明与使用 1.1 索引的分类 MySQL索引包括普通索引.唯一性索引.全文索引.单列索引.多列索引和空间索引 按照逻辑结构划分,主要有四种:普通索引.唯一性索引. ...
- c/c++零基础坐牢第二天
c/c++从入门到入土(2) 开始时间2023-04-13 23:02:34 结束时间2023-04-14 01:26:05 前言:如果第一天没把你劝退,恭喜你!通过今天的学习你就能半步踏进编程的大门 ...
- 聊一聊redis十种数据类型及底层原理
概述 Redis 是一个开源的高性能键值数据库,它支持多种数据类型,可以满足不同的业务需求.本文将介绍 Redis 的10种数据类型,分别是 string(字符串) hash(哈希) list(列表) ...
- laravel框架三级联动,详细代码
这里运用到省份表中,下面是效果图 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 需要一个省份表,里面的字段要有个pid,name这些字段 下面是控制器代码,(Cit ...
- .NET Core 离线生成 Tron 波场私钥和地址笔记
NuGet 引入依赖库 PM> Install-Package Tron.Wallet.Net 随机生成私钥和对应的地址 using Tron.Wallet.Net; namespace Con ...
- PHP获取网页返回的JSON数据并在微信换行展示
1 $url ="http://japi.juhe.cn/joke/content/text.from?page=&pagesize=&key=c968d04ab0ea15e ...
- 2020-10-02:golang如何写一个插件?
福哥答案2020-10-02:#福大大架构师每日一题#简单回答:buildmode=plugin plugin.Openp.Lookup [中级回答:](https://www.zhihu.com/q ...
- 2020-09-18:LRU手撸,说下时间复杂度和空间复杂度。
福哥答案2020-09-18: 方法:哈希表 + 双向链表.时间复杂度:对于 put 和 get 都是 O(1).空间复杂度:O(capacity),因为哈希表和双向链表最多存储 capacity+1 ...
- 2021-08-20:打砖块。有一个 m x n 的二元网格,其中 1 表示砖块,0 表示空白。砖块 稳定(不会掉落)的前提是:1.一块砖直接连接到网格的顶部,或者,2.至少有一块相邻(4 个方向之一
2021-08-20:打砖块.有一个 m x n 的二元网格,其中 1 表示砖块,0 表示空白.砖块 稳定(不会掉落)的前提是:1.一块砖直接连接到网格的顶部,或者,2.至少有一块相邻(4 个方向之一 ...