Skip to main content
QUICK REVIEW

[论文解读] The Topological BERT: Transforming Attention into Topology for Natural Language Processing

Ilan Perez, Raphael Reinauer|arXiv (Cornell University)|Jun 30, 2022
Topological and Geometric Data Analysis被引用 11
一句话总结

本文提出 Topological BERT,一种新型文本分类器,将 BERT 的注意力图转化为注意力图,并应用拓扑数据分析——特别是持久同调和持久图像——以提取结构特征用于分类。该方法在情感分析和语法正确性判断等 NLP 任务上表现与 BERT 相当,同时可实现对注意力头的激进剪枝(最低至 10 个)而性能无损失,并展现出对对抗性攻击的优越鲁棒性。

ABSTRACT

In recent years, the introduction of the Transformer models sparked a revolution in natural language processing (NLP). BERT was one of the first text encoders using only the attention mechanism without any recurrent parts to achieve state-of-the-art results on many NLP tasks. This paper introduces a text classifier using topological data analysis. We use BERT's attention maps transformed into attention graphs as the only input to that classifier. The model can solve tasks such as distinguishing spam from ham messages, recognizing whether a sentence is grammatically correct, or evaluating a movie review as negative or positive. It performs comparably to the BERT baseline and outperforms it on some tasks. Additionally, we propose a new method to reduce the number of BERT's attention heads considered by the topological classifier, which allows us to prune the number of heads from 144 down to as few as ten with no reduction in performance. Our work also shows that the topological model displays higher robustness against adversarial attacks than the original BERT model, which is maintained during the pruning process. To the best of our knowledge, this work is the first to confront topological-based models with adversarial attacks in the context of NLP.

研究动机与目标

  • 开发一种基于拓扑的文本分类器,利用 BERT 的注意力机制,而无需依赖微调后的 BERT 参数。
  • 探究注意力图的拓扑表示是否能在标准 NLP 基准上达到或超越 BERT 的性能。
  • 设计一种基于拓扑可解释性的新型注意力头剪枝方法,降低模型复杂度而不造成性能下降。
  • 评估拓扑模型在对抗性攻击下的鲁棒性,这是拓扑 NLP 领域此前未被探索的方向。
  • 通过 UMAP 投影中的拓扑稳定性与聚类,探索注意力头的可解释性。

提出的方法

  • 将 BERT 的多头注意力图转换为每层和每序列的加权有向注意力图。
  • 应用持久同调计算拓扑特征,如贝蒂数和持久图像,覆盖多个同调维度。
  • 将持久图象用作全连接神经网络的输入特征,用于下游分类。
  • 提出一种类似 GradCam 的方法,基于注意力头对拓扑特征的贡献程度进行评分,以实现剪枝。
  • 对持久图像应用数据增强与标准化技术,包括旋转、填充和帧特定归一化。
  • 在特定任务数据集上端到端训练拓扑分类器,采用早停法与学习率调度策略。

实验结果

研究问题

  • RQ1从 BERT 注意力图中提取的拓扑特征是否能在标准 NLP 基准上实现与 BERT 相当的性能?
  • RQ2基于拓扑相关性剪枝注意力头是否能保持甚至提升分类准确率与鲁棒性?
  • RQ3不同过滤类型(普通、多维、有向)及对称性函数如何影响拓扑模型的性能?
  • RQ4持久图的 UMAP 投影与 BERT 注意力图的聚类模式之间是否存在相关性?
  • RQ5拓扑模型是否能保持对对抗性攻击的鲁棒性?剪枝是否影响这种鲁棒性?

主要发现

  • 拓扑模型在所有评估任务上均达到与 BERT 相当的性能,IMDB 数据集准确率达 99.8%,SST-2 数据集准确率达 89.0%。
  • 使用所提出的拓扑评分方法将注意力头从 144 个剪枝至 10 个后,性能保持不变,仅出现轻微准确率下降(例如 CoLA 数据集上 3 个头时为 0.554/81.9,而 BERT 为 0.518/80.6)。
  • 当使用 20 个微调周期时,该模型在 CoLA 数据集上的表现优于 BERT,1 个头时准确率达 0.591/83.3,而 BERT 为 0.518/80.6。
  • 拓扑模型在对抗性攻击下表现出显著更高的鲁棒性,且即使剪枝至 10 个头后,该鲁棒性依然保持。
  • 从普通和有向过滤中计算的持久图像,尤其是经过剪枝后,优于更复杂的过滤方式(如 MultiDim),在 CoLA 数据集上使用 30 个头时达到 82.4% 的峰值准确率。
  • 剪枝后选定的注意力头主要聚焦于 [SEP] 标记,为“无操作”假说提供了新见解,并暗示注意力头存在功能特化。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。