通过打乱与掩码位置编码,提升Transformer在视觉和语言任务中的鲁棒性与性能
A Unified Masked Jigsaw Puzzle Framework for Vision and Language Models
- 打乱输入顺序并用可学习的未知位置嵌入掩码原位置信息
- 在ImageNet-1K和Yelp/Amazon数据集上同时提升准确率与抗梯度攻击能力
- 适用于多模态Transformer模型,开源代码可复现
在联邦学习中,Transformer作为主流架构面临梯度攻击防御难与跨视觉(CV)与自然语言处理(NLP)任务性能提升的挑战。研究发现,位置嵌入(PEs)的梯度包含足够信息,足以重构输入数据。为此,本文提出统一的掩码拼图(MJP)框架:先随机打乱标记顺序,再使用可学习的未知(unk)位置嵌入掩码打乱后标记的位置编码。该方法破坏了位置编码所承载的局部空间信息,迫使模型学习对局部结构不敏感的特征表示。实验表明,采用MJP可显著提升模型对梯度攻击的鲁棒性,并在图像分类(如ImageNet-1K)与文本情感分析(如Yelp、Amazon)任务中实现性能提升。结果验证了MJP是适用于视觉与语言任务中多种Transformer模型的统一框架。代码已开源:https://github.com/ywxsuperstar/transformerattack
原文摘要 · Abstract (English)
In federated learning, Transformer, as a popular architecture, faces critical challenges in defending against gradient attacks and improving model performance in both Computer Vision (CV) and Natural Language Processing (NLP) tasks. It has been revealed that the gradient of Position Embeddings (PEs) in Transformer contains sufficient information, which can be used to reconstruct the input data. To mitigate this issue, we introduce a Masked Jigsaw Puzzle (MJP) framework. MJP starts with random token shuffling to break the token order, and then a learnable \textit{unknown (unk)} position embedding is used to mask out the PEs of the shuffled tokens. In this manner, the local spatial information which is encoded in the position embeddings is disrupted, and the models are forced to learn feature representations that are less reliant on the local spatial information. Notably, with the careful use of MJP, we can not only improve models' robustness against gradient attacks, but also boost their performance in both vision and text application scenarios, such as classification for images (\textit{e.g.,} ImageNet-1K) and sentiment analysis for text (\textit{e.g.,} Yelp and Amazon). Experimental results suggest that MJP is a unified framework for different Transformer-based models in both vision and language tasks. Code is publicly available via https://github.com/ywxsuperstar/transformerattack
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。