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 ...
随机推荐
- 迁移学习()《Attract, Perturb, and Explore: Learning a Feature Alignment Network for Semi-supervised Domain Adaptation》
论文信息 论文标题:Attract, Perturb, and Explore: Learning a Feature Alignment Network for Semi-supervised Do ...
- day128:MySQL进阶:MySQL安装&用户/权限/连接/配置管理&MySQL的体系结构&SQL&MySQL索引和执行计划
目录 1.介绍和安装 2.基础管理 2.1 用户管理 2.2 权限管理 2.3 连接管理 2.4 配置管理 3.MySQL的体系结构 4.SQL 5.索引和执行计划 1.介绍和安装 1.1 数据库分类 ...
- day14:列表/集合/字典推导式&生成器表达式&生成器函数
推导式 推导式的定义: 通过一行循环判断,遍历一系列数据的方式 推导式的语法: val for val in Iterable 三种方式: [val for val in Iterable] {val ...
- CentOS7.6静默安装19C实例脚本 ORA-27125 [FATAL] [DBT-10322]
脚本: dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname test -sid test -characte ...
- PHP的WAMP的安装
WAMP独立安装 软件官网下载: Apache:http://httpd.apache.org/download.cgi MySQL:http://dev.mysql.com/downloads/ P ...
- 关于 OAuth 你又了解哪些?
作者罗锦华,API7.ai 技术专家/技术工程师,开源项目 pgcat,lua-resty-ffi,lua-resty-inspect 的作者. OAuth 的背景 OAuth,O 是 Open,Au ...
- 20130625-关于mac配置android cocos2dx
1.下载cocos2dx ndk eclipse http://developer.android.com/tools/sdk/ndk/index.html 2.cocos2dx文件中找到crea ...
- 一个.Net版本的ChatGPT SDK
ChatGPT大火,用它来写代码.写表白书.写文章.写对联.写报告.写周边...... 啥都会! 个人.小公司没有能力开发大模型,但基于开放平台,根据特定的场景开发应用,却是非常火热的. 为了避免重复 ...
- 为什么 Go for-range 的 value 值地址每次都一样?
原文链接: 为什么 Go for-range 的 value 值地址每次都一样? 循环语句是一种常用的控制结构,在 Go 语言中,除了 for 关键字以外,还有一个 range 关键字,可以使用 fo ...
- ai问答:使用 Vue3 组合式API 和 TS 父子组件共享数据
这是一个使用 Vue3 组合式 API 和 TypeScript 的简单父子组件共享数据示例 父组件 Parent.vue: <template> <div> <p> ...