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 ...
随机推荐
- ViewGroup的TouchTarget设计思维
TouchTarget需要创建的时候先看下池子里面有没有被回收上来的,如果没有可以利用的就给你创建一个新的,否则就从池子里面把头部的那个可以利用的给你,你把你的东西放进去就行了.回收的时候就是把你放在 ...
- API 网关日志的价值,你了解多少?
本文介绍了 API 网关日志的价值,并以知名网关 Apache APISIX 为例,展示如何集成 API 网关日志. 作者钱勇,API7.ai 技术工程师,Apache APISIX Committe ...
- 使用Java接入小程序订阅消息!
更新完微信服务号的模板消息之后,我又赶紧把微信小程序的订阅消息给实现了!之前我一直以为微信小程序也是要企业才能申请,没想到小程序个人就能申请. 消息推送平台推送下发[邮件][短信][微信服务号][微信 ...
- 原来这就是所谓的 JSR!
相信大家在学习 Java 的过程中,或多或少都见过 JSR 这个词.本篇文章就科普下什么是 JSR. 什么是 JSR ? JSR(Java Specification Requests),是指 Jav ...
- Ajax 以及 Ajax基于Promise封装
AJAX - 创建 XMLHttpRequest 对象 var xmlhttp = new XMLHttpRequest(); 通过打印实例对象我们发现,我们打印的是 xmlhttp 对象,里面所有的 ...
- Git&GitHub简介与入手(二)
四.GitHub 1.建账号,仓库 https://github.com/ 用邮箱在官网注册: 增加远程库的地址取别名为origin,push为推送,fetch为取回: 2.推送操作 将本地当前所在 ...
- 2022-08-16:绳子总长度为M, 100 -> M, (6, 100) (7,23) (10,34) -> arr, 每一个长度的绳子对应一个价格,比如(6, 10)表示剪成长度为6的绳子,对应
2022-08-16:绳子总长度为M, 100 -> M, (6, 100) (7,23) (10,34) -> arr, 每一个长度的绳子对应一个价格,比如(6, 10)表示剪成长度为6 ...
- 2021-02-07:给定两棵二叉树的头节点head1和head2,如何判断head1中是否有某个子树的结构和head2完全一样?
福哥答案2021-02-07: 对head1和head2序列化为str1和str2.然后用kmp算法去判断str2是否是str1的子串.如果是,head2是子树:如果不是,head2不是子树. 代码用 ...
- 2022-01-01:给定int[][] meetings,比如 { {66, 70} 0号会议截止时间66,获得收益70 {25, 90} 1号会议截止时间25,获得收益90
2022-01-01:给定int[][] meetings,比如 { {66, 70} 0号会议截止时间66,获得收益70 {25, 90} 1号会议截止时间25,获得收益90 {50, 30} 2号 ...
- asp.net WebApi JWT
文章转自 https://blog.csdn.net/liwan09/article/details/83820651 参考资料: https://docs.microsoft.com/en-us/a ...