Explaining how transformers use context to build predictions

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 advan...

Full description

Bibliographic Details
Authors: Ferrando Monsonís, Javier|||0000-0002-2637-0961, Gallego Olsina, Gerard Ion|||0000-0001-7466-3606, Tsiamas, Ioannis|||0000-0003-1049-2515, Ruiz Costa-jussà, Marta
Format: report
Publication Date:2023
Country:España
Institution:Universitat Politècnica de Catalunya (UPC)
Repository:UPCommons. Portal del coneixement obert de la UPC
Language:English
OAI Identifier:oai:upcommons.upc.edu:2117/390792
Online Access:https://hdl.handle.net/2117/390792
Access Level:Open access
Keyword:Machine translating
Natural language processing (Computer science)
Traducció automàtica
Tractament del llenguatge natural (Informàtica)
Àrees temàtiques de la UPC::Enginyeria de la telecomunicació::Processament del senyal::Processament de la parla i del senyal acústic
Àrees temàtiques de la UPC::Informàtica::Intel·ligència artificial::Llenguatge natural
Description
Summary: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.