Introduction
While Transformer-based models like BERT have revolutionized Natural Language Processing, achieving near-human performance on benchmarks such as SQuAD, they are often criticized as "black boxes." Unlike earlier modular architectures like BiDAF, which possessed explicit stages for encoding and attention, BERT consists of a stack of identical Transformer blocks. This research investigates whether these layers evolve to perform specific logical steps required for Reading Comprehension Question Answering (RCQA), such as identifying query terms and isolating answer spans.
Methodology
The study utilizes Integrated Gradients (IG) to attribute importance scores to input words at each of BERT's 12 layers. By categorizing passage words into query words (from the question), answer words (ground truth), and supporting words (contextual neighbors), the authors track how word importance shifts through the network.
To quantify the similarity of these importance distributions between layers, the researchers employed Jensen-Shannon Divergence (JSD). A critical part of their analysis involved comparing distributions when the "top 2" most important words were either retained or removed. This comparison helps determine if a layer's functional role is defined by its most significant attributions or by the broader distribution of word importance.
Functional Evolution Across Layers
The analysis reveals a clear functional pipeline within BERT. Initial layers (0-2) primarily serve as a "search engine," assigning high importance to query words found within the text. As information progresses through the middle layers (3-8), the focus shifts toward contextual processing. In the final layers (9-11), the model "zooms in" on the answer span and its immediate supporting context.
This evolution is reflected in the data: in SQuAD, the importance of query words decreases from 22.94% at Layer 0 to 12.0% at Layer 11, while the importance of the answer span grows from 26.99% to 34.63% over the same span.
The Quantifier Paradox
A specific focus was placed on "quantifier" questions (e.g., "How many...?"). Interestingly, the authors found that in the final layers, BERT increases its attention on "confusing" numerical candidates—other numbers in the text that are not the answer. Despite this potential distraction, the model maintains high accuracy (87.35% EM on SQuAD). This suggests that BERT's final layers are not merely ignoring distractors but are actively performing a comparative analysis to select the correct candidate from a set of possibilities.
Representation Migration
Using t-SNE visualizations, the study observed how word embeddings migrate through the 12 layers of BERT-BASE. At Layer 0, words cluster by lexical type (e.g., all numbers together). By Layer 4, these clusters dissolve as the model processes complex interactions between words. By the final layer, the answer word physically segregates itself from the rest of the embeddings, indicating a clear decision-making state where the target information is isolated from the background noise.
Conclusion
This work provides evidence that BERT's homogeneous architecture develops a heterogeneous functional pipeline for RCQA. The findings suggest that a layer's role is primarily defined by its top-ranked words, as shown by the significant drop in JSD when these words are removed. While the model successfully distinguishes between similar candidates, the exact logic of this "process of elimination" remains a subject for future research. Extending this layer-wise attribution to multi-hop reasoning and comparing it across different Transformer variants (e.g., RoBERTa or ALBERT) are promising next steps.
Summary updated