Proceedings

AttExplainer: Explain Transformer via Attention by Reinforcement Learning

Video #1 Video #2 Download BibTeX Cite

Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence. Main Track. Pages 724-731.

https://doi.org/10.24963/ijcai.2022/102

Abstract

Transformer and its variants, built based on attention mechanisms, have recently achieved remarkable performance in many NLP tasks. Most existing works on Transformer explanation tend to reveal and utilize the attention matrix with human subjective intuitions in a qualitative manner. However, the huge size of dimensions directly challenges these methods to quantitatively analyze the attention matrix. Therefore, in this paper, we propose a novel reinforcement learning (RL) based framework for Transformer explanation via attention matrix, namely AttExplainer. The RL agent learns to perform step-by-step masking operations by observing the change in attention matrices. We have adapted our method to two scenarios, perturbation-based model explanation and text adversarial attack. Experiments on three widely used text classification benchmarks validate the effectiveness of the proposed method compared to state-of-the-art baselines. Additional studies show that our method is highly transferable and consistent with human intuition. The code of this paper is available at https://github.com/niuzaisheng/AttExplainer .

  1. [Abnar and Zuidema, 2020] Samira Abnar and Willem Zuidema. Quantifying attention flow in transformers. In ACL, 2020. [Alzantot and others, 2018] Moustafa Alzantot et al. Gener- ating natural language adversarial examples. In EMNLP, 2018.
  2. [Bowman and others, 2015] Samuel R. Bowman et al. A large annotated corpus for learning natural language in- ference. In EMNLP, 2015.
  3. [Castro et al., 2009] Javier Castro, Daniel Gómez, and Juan Tejada. Polynomial calculation of the shapley value based on sampling. Computers & Operations Research, 2009.
  4. [Chefer et al., 2021] Hila Chefer, Shir Gur, and Lior Wolf. Transformer interpretability beyond attention visualiza- tion. In CVPR, 2021.
  5. [Devlin and others, 2019] Jacob Devlin et al. BERT: Pre- training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
  6. [Ebrahimi et al., 2018] Javid Ebrahimi, Anyi Rao, Daniel Lowd, and Dejing Dou. HotFlip: White-box adversarial examples for text classification. In ACL, 2018.
  7. [Feng and others, 2018] Shi Feng et al. Pathologies of neural models make interpretations difficult. In EMNLP, 2018.
  8. [Gao et al., 2018] Ji Gao, Jack Lanchantin, Mary Lou Soffa, and Yanjun Qi. Black-box generation of adversarial text sequences to evade deep learning classifiers. In 2018 IEEE Security and Privacy Workshops (SPW), 2018.
  9. [Hewitt and Manning, 2019] John Hewitt and Christo- pher D. Manning. A structural probe for finding syntax in word representations. In NAACL-HLT, 2019.
  10. [Htut et al., 2019] Phu Mon Htut, Jason Phang, Shikha Bor- dia, and Samuel R. Bowman. Do attention heads in bert track syntactic dependencies? arXiv preprint arXiv: 1911.12246, 2019.
  11. [Iyyer et al., 2018] Mohit Iyyer, John Wieting, Kevin Gim- pel, and Luke Zettlemoyer. Adversarial example genera- tion with syntactically controlled paraphrase networks. In NAACL-HLT, 2018.
  12. [Jain and Wallace, 2019] Sarthak Jain and Byron C. Wallace. Attention is not Explanation. In NAACL-HLT, 2019.
  13. [Kingma and Ba, 2015] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
  14. [Kokhlikyan et al., 2020] Narine Kokhlikyan, Vivek Miglani, Miguel Martin, Edward Wang, Bilal Alsal- lakh, Jonathan Reynolds, Alexander Melnikov, Natalia Kliushkina, Carlos Araya, Siqi Yan, and Orion Reblitz- Richardson. Captum: A unified and generic model interpretability library for pytorch. arXiv preprint arXiv:2009.07896, 2020.
  15. [Kovaleva et al., 2019] Olga Kovaleva, Alexey Romanov, Anna Rogers, and Anna Rumshisky. Revealing the dark secrets of BERT. In EMNLP, 2019.
  16. [Li et al., 2016a] Jiwei Li, Will Monroe, and Dan Juraf- sky. Understanding neural networks through representa- tion erasure. arXiv preprint arXiv:1612.08220, 2016.
  17. [Li et al., 2016b] Jiwei Li, Will Monroe, Alan Ritter, Dan Jurafsky, Michel Galley, and Jianfeng Gao. Deep rein- forcement learning for dialogue generation. In EMNLP, 2016.
  18. [Li et al., 2019] Jinfeng Li, Shouling Ji, Tianyu Du, Bo Li, and Ting Wang. TextBugger: Generating adversarial text against real-world applications. In Proceedings 2019 Net- work and Distributed System Security Symposium. Internet Society, 2019.
  19. [Li et al., 2020] Linyang Li, Ruotian Ma, Qipeng Guo, Xi- angyang Xue, and Xipeng Qiu. BERT-ATTACK: Adver- sarial attack against BERT using BERT. In EMNLP, 2020.
  20. [Lundberg and Lee, 2017] Scott M. Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In NIPS, 2017.
  21. [Papernot et al., 2016] Nicolas Papernot, Patrick Mcdaniel, Ananthram Swami, and Richard E. Harang. Crafting ad- versarial input sequences for recurrent neural networks. MILCOM, 2016.
  22. [Ren et al., 2019] Shuhuai Ren, Yihe Deng, Kun He, and Wanxiang Che. Generating natural language adversarial examples through probability weighted word saliency. In ACL, 2019.
  23. [Ribeiro et al., 2016] Marco Túlio Ribeiro, Sameer Singh, and Carlos Guestrin. "why should I trust you?": Explain- ing the predictions of any classifier. In SIGKDD, 2016.
  24. [Saravia et al., 2018] Elvis Saravia, Hsien-Chi Toby Liu, Yen-Hao Huang, Junlin Wu, and Yi-Shin Chen. CARER: Contextualized affect representations for emotion recogni- tion. In EMNLP, 2018.
  25. [Schaul et al., 2016] Tom Schaul, John Quan, Ioannis Antonoglou, and David Silver. Prioritized experience re- play. In ICLR, 2016.
  26. [Serrano and Smith, 2019] Sofia Serrano and Noah A. Smith. Is attention interpretable? In ACL, 2019.
  27. [Vaswani and others, 2017] Ashish Vaswani et al. Attention is all you need. In NIPS, 2017.
  28. [Wallace and others, 2019] Eric Wallace et al. AllenNLP in- terpret: A framework for explaining predictions of NLP models. In EMNLP, 2019.
  29. [Wang and others, 2019] Alex Wang et al. GLUE: A multi- task benchmark and analysis platform for natural language understanding. In ICLR, 2019.
  30. [Wiegreffe and Pinter, 2019] Sarah Wiegreffe and Yuval Pin- ter. Attention is not not explanation. In EMNLP, 2019.
  31. [Wolf et al., 2019] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Huggingface's transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019.
  32. [Wu et al., 2020] Zhiyong Wu, Yun Chen, Ben Kao, and Qun Liu. Perturbed masking: Parameter-free probing for ana- lyzing and interpreting BERT. In ACL, 2020.
  33. [Xiong et al., 2018] Caiming Xiong, Victor Zhong, and Richard Socher. DCN+: mixed objective and deep residual coattention for question answering. In ICLR, 2018.
  34. [Xu et al., 2019] Jingjing Xu, Liang Zhao, Hanqi Yan, Qi Zeng, Yun Liang, and Xu Sun. LexicalAT: Lexical- based adversarial reinforcement training for robust senti- ment classification. In EMNLP, 2019.
  35. [Zang et al., 2020] Yuan Zang, Fanchao Qi, Chenghao Yang, Zhiyuan Liu, Meng Zhang, Qun Liu, and Maosong Sun. Word-level textual adversarial attacking as combinatorial optimization. In ACL, 2020.
  36. [Zeiler and Fergus, 2014] Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In ECCV, 2014.
  37. [Zeng and others, 2021] Guoyang Zeng et al. OpenAttack: An open-source textual adversarial attack toolkit. In ACL, 2021.
  38. [Zhao et al., 2018] Zhengli Zhao, Dheeru Dua, and Sameer Singh. Generating natural adversarial examples. In ICLR, 2018.
  39. [Zhong et al., 2017] Victor Zhong, Caiming Xiong, and Richard Socher. Seq2sql: Generating structured queries from natural language using reinforcement learning. arXiv preprint arXiv:1709.00103, 2017.
  40. [Zou et al., 2020] Wei Zou, Shujian Huang, Jun Xie, Xinyu Dai, and Jiajun Chen. A reinforced generation of adver- sarial examples for neural machine translation. In ACL, 2020.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards