Explaining How Transformers Use Context to Build Predictions

Javier Ferrando, Gerard I. Gállego, Ioannis Tsiamas, Marta R. Costa-jussà


Abstract
Language Generation Models produce words based on the previous context. Although existing methods offer input attributions as explanations for a model’s prediction, it is still unclear how prior words affect the model’s decision throughout the layers. In this work, we leverage recent advances in explainability of the Transformer and present a procedure to analyze models for language generation. Using contrastive examples, we compare the alignment of our explanations with evidence of the linguistic phenomena, and show that our method consistently aligns better than gradient-based and perturbation-based baselines. Then, we investigate the role of MLPs inside the Transformer and show that they learn features that help the model predict words that are grammatically acceptable. Lastly, we apply our method to Neural Machine Translation models, and demonstrate that they generate human-like source-target alignments for building predictions.
Anthology ID:
2023.acl-long.301
Volume:
Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)
Month:
July
Year:
2023
Address:
Toronto, Canada
Editors:
Anna Rogers, Jordan Boyd-Graber, Naoaki Okazaki
Venue:
ACL
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
5486–5513
Language:
URL:
https://aclanthology.org/2023.acl-long.301
DOI:
10.18653/v1/2023.acl-long.301
Bibkey:
Cite (ACL):
Javier Ferrando, Gerard I. Gállego, Ioannis Tsiamas, and Marta R. Costa-jussà. 2023. Explaining How Transformers Use Context to Build Predictions. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5486–5513, Toronto, Canada. Association for Computational Linguistics.
Cite (Informal):
Explaining How Transformers Use Context to Build Predictions (Ferrando et al., ACL 2023)
Copy Citation:
PDF:
https://aclanthology.org/2023.acl-long.301.pdf
Video:
 https://aclanthology.org/2023.acl-long.301.mp4