Standard practice in natural language processing involves extracting the final hidden state of a Transformer encoder to represent a token or a sequence. However, this "last-layer-only" approach assumes that the final layer is the most informative for every downstream task. A growing body of research suggests that this creates an information bottleneck, as the final layer is often highly specialized for the model's pre-training objective (like predicting a masked word) and may lose the rich, multi-grain features distributed throughout the network's depth.
The Linguistic Hierarchy of Layers
Transformers naturally develop a hierarchy of representations. Early layers tend to capture low-level syntactic information and local keywords, while deeper layers capture high-level semantic structures and abstract context. Jang et al. argue that by aggregating information from multiple depths, models can capture a more comprehensive profile ranging from syntax to semantics. Similarly, Dubrov et al. found that pooling representations from all intermediate layers improves performance on complex classification tasks by capturing a broader range of information than the final layer alone.
This hierarchical view is particularly important for tasks requiring structural understanding. Shi et al. demonstrate that averaging across all layers provides a more stable syntactic signal for unsupervised probing, mitigating the variability of linguistic information stored at different depths.
Mechanisms for Layer Fusion
Researchers have proposed several strategies to synthesize these multi-level representations, ranging from simple pooling to complex attention mechanisms:
- Pooling and Concatenation: The simplest methods involve element-wise operations. Luo et al. use max-pooling across the final layers to create robust semantic representations. Others, such as Jiang et al. and Bai, prefer concatenating the hidden states of the final several layers, providing the downstream classifier with a high-dimensional snapshot of the model's internal state.
- Weighted Averaging: Rather than treating all layers equally, many models learn to weight them. Mihalcea and Soler et al. show that averaging the final four layers captures richer semantic features for figurative language and word similarity. Li further demonstrates that a weighted sum of all hidden layers provides more robust embeddings for sarcasm detection.
- Attention-Based Fusion: More sophisticated methods use attention to dynamically select relevant features. Tang et al. introduce Multi-Layers Trainable Pooling, using cross-attention to aggregate semantic nuances from all internal layers. Cao et al. propose "Attention Fusion," which uses a tiny task-specific query to aggregate information from a frozen backbone, achieving performance comparable to full fine-tuning with a fraction of the parameters.
Overcoming the Entanglement Problem
A primary motivation for multi-layer aggregation is the "entangled" nature of the final layer. Lin et al. argue that standard Transformers often fail at compositional generalization because they rely on a single representation from the final layer. By blending representations from all layers, their COMPOSITION method provides the decoder with a task-specific mix of syntactic and semantic information.
Furthermore, the final layer can suffer from a mathematical bottleneck. Chang et al. show that the standard softmax output layer limits representational capacity. By concatenating projected features from multiple preceding layers, they provide the model with additional degrees of freedom, improving factuality and reducing hallucinations in generative tasks.
Efficiency and Transferability
Beyond accuracy, multi-layer aggregation improves the utility of pre-trained models. Garbaciauskas et al. found that averaging hidden states across all layers significantly improves the accuracy of transferability estimators, allowing researchers to better predict which model will perform best on a new task without expensive fine-tuning.
For resource-constrained environments, Guo demonstrates that mining a model's own internal hidden states across multiple layers can create ultra-efficient reward models (SWIFT) that outperform much larger standalone models. This suggests that the information needed for complex reasoning and self-assessment is already present within the network's depth, waiting to be aggregated.
Key Foundational Work
Deepening Hidden Representations from Pre-trained Language Models (2019) — contributed 2 concept elements to this direction.
Kingsoft’s Neural Machine Translation System for WMT19 (2019) — contributed 2 concept elements to this direction.