Abstract
Contextual representation models have achieved great success in improving various downstream tasks. However, these language-model-based encoders are difficult to train due to the large parameter sizes and high computational complexity. By carefully examining the training procedure, we find that the softmax layer (the output layer) causes significant inefficiency due to the large vocabulary size. Therefore, we redesign the learning objective and propose an efficient framework for training contextual representation models. Specifically, the proposed approach bypasses the softmax layer by performing language modeling with dimension reduction, and allows the models to leverage pre-trained word embeddings. Our framework reduces the time spent on the output layer to a negligible level, eliminates almost all the trainable parameters of the softmax layer and performs language modeling without truncating the vocabulary. When applied to ELMo, our method achieves a 4 times speedup and eliminates 80% trainable parameters while achieving competitive performance on downstream tasks.
Introduction
Contextual representation models such as ELMo, BERT, and GPT have revolutionized natural language processing. However, these models are notoriously resource-hungry. For instance, the original ELMo required two weeks of training on a one-billion-token corpus using multiple GPUs. The primary culprit for this inefficiency is the softmax layer.
In a standard language model, the output layer must predict a probability for every word in the vocabulary. With large vocabularies (e.g., 800,000 words for ELMo), this layer becomes a massive bottleneck in terms of computation and memory. Furthermore, the output layer weights often account for over 80% of the total model parameters, yet this component is typically discarded after training when the model is used as a feature extractor for downstream tasks. Spending the vast majority of resources on a component that is eventually thrown away is highly inefficient.
Methodology: Bypassing the Softmax
The authors propose a framework that redesigns the learning objective to bypass the softmax layer entirely, focusing on the "encoder" part of the model.
The SEMFIT Layer
Instead of predicting a word index via a probability distribution, the model is trained to predict the pre-trained word embedding (e.g., FastText) of the target word. This "SEMFIT" layer changes the training objective from maximizing log-likelihood to minimizing the distance (such as cosine distance) between the encoder's output and a fixed, pre-trained target embedding.
Decoupling and Open-Vocabulary Training
By using fixed, pre-trained embeddings as targets, the model decouples the difficulty of learning word meanings from the task of learning contextual behavior. Furthermore, using subword-based embeddings allows for "open-vocabulary" training, where the model can handle an untruncated vocabulary without the computational penalty of a massive softmax matrix.
Experimental Results
The proposed model, ELMo-S, was trained on the One Billion Word Benchmark and evaluated against the original ELMo and a version using Adaptive Softmax (ELMo-A).
Efficiency Gains
ELMo-S achieved a significant 4.2x speedup over the original ELMo. Trainable parameters were reduced from 499 million to just 76 million—an 85% reduction. This efficiency allowed for much larger batch sizes (768 vs. 128), further accelerating training on modern hardware.
Downstream Performance
Evaluation across benchmarks like SNLI, Coreference Resolution, and Sentiment Analysis (SST-5) showed that ELMo-S performs competitively with the original ELMo. While there was a slight performance degradation on syntactic tasks like Named Entity Recognition (NER) and Semantic Role Labeling (SRL), the model still significantly outperformed non-contextual baselines. The choice of target embedding matters; using targets that capture syntactic information (like trained CNN layers) can help bridge the gap for syntactic tasks.
Conclusion
The SEMFIT approach demonstrates that the softmax layer is optional for learning high-quality contextual representations. By replacing the expensive probability distribution with a regression-like objective targeting pre-trained embeddings, training becomes significantly faster and more memory-efficient. While this method is not suitable for text generation, it provides a powerful and efficient alternative for building feature-based contextual encoders.
Summary updated