Obtaining Better Static Word Embeddings Using Contextual Embedding Models

Prakhar Gupta, Martin Jaggi

Introduction

In modern Natural Language Processing (NLP), a significant tension exists between model quality and computational efficiency. Contextual models like BERT, RoBERTa, and GPT-2 have revolutionized the field by generating word representations based on surrounding context. However, these models are computationally expensive, often requiring billions of operations for a single inference call, which limits their utility in latency-sensitive or resource-constrained environments.

Conversely, static embeddings such as Word2Vec, GloVe, and FastText are extremely efficient, relying on simple lookup tables. Their primary drawback is a lack of "intelligence"; because they assign a single fixed vector to each word regardless of context, they struggle to capture complex semantic nuances. This paper introduces a distillation framework designed to bridge this gap, leveraging the power of contextual "teachers" to train high-performance static "student" embeddings.

The X2STATIC Framework

The researchers propose X2STATIC, a method to bake the structural knowledge of massive Transformers into lightweight static vectors. The framework builds upon the Continuous Bag-of-Words (CBOW) architecture and its extension, Sent2Vec.

In a traditional CBOW setup, a model predicts a target word based on a simple average of surrounding word vectors. X2STATIC replaces this basic aggregation with a sophisticated context representation generated by a pre-trained contextual model (the teacher). During training on a large corpus, the teacher processes the context (either a sentence or a paragraph) and provides a high-quality representation. The static embedding model (the student) is then trained to predict the target word using the teacher's output as its input context.

Two variants were explored:

  • X2STATIC_sent: Uses individual sentences as context.
  • X2STATIC_para: Uses entire paragraphs, providing broader thematic context and improving computational efficiency during the training phase.

Experimental Setup and Results

The models were trained on an English Wikipedia dump containing approximately 1.28 billion words. Evaluation spanned five unsupervised word-similarity datasets (including SimLex-999 and RW-2034) and six supervised downstream classification tasks.

Performance Comparison

The distilled models significantly outperformed traditional baselines. As shown in the comprehensive results table below, the X2STATIC variants (highlighted in blue) consistently achieved higher Spearman’s $\rho$ scores across nearly all benchmarks compared to FastText and GloVe.

Table 1: Performance of distilled models compared to traditional baselines and existing pre-trained models across multiple word-similarity datasets.

Notably, RoBERTa2STATIC_para achieved a score of 0.5544 on SimLex-999, a substantial improvement over FastText (0.416) and GloVe (0.3764). In supervised tasks like SST-5 sentiment analysis, the distilled models also outperformed traditional static embeddings, demonstrating that the semantic richness captured during training translates effectively to downstream applications.

Scalability and Data Efficiency

A key insight from the study is that X2STATIC scales effectively with more data. Previous methods for extracting static vectors from BERT, such as ASE (which averages BERT's outputs for a word across multiple contexts), tend to saturate quickly. In contrast, X2STATIC continues to improve as it processes more of the Wikipedia corpus.

Figure 1: Performance of various models on SIMLEX-999 and RW-2034 as a function of the fraction of the Wikipedia dataset used during training.

As illustrated in the scaling plots, the X2STATIC models (solid lines) maintain an upward trajectory in performance as the training data increases, whereas the ASE baselines (dashed lines) plateau. This suggests that the distillation process successfully "learns" word identities rather than just aggregating specific instances.

Discussion and Future Work

The primary advantage of X2STATIC is its extreme efficiency at inference time. Once trained, these embeddings are tens of millions of times faster to use than their Transformer-based teachers, essentially providing the speed of a lookup table with a significant portion of a Transformer's semantic accuracy.

However, limitations remain. The training process is computationally intensive, requiring high-end GPUs for 15–38 hours. Furthermore, as static embeddings, they still suffer from the "one vector per word" problem, meaning they cannot distinguish between different meanings of polysemous words (e.g., "bank") at runtime. Future research may focus on applying this distillation framework to learn sense-specific embeddings or extending the method to low-resource languages using multilingual teacher models.

Conclusion

X2STATIC demonstrates that contextual models can be used to significantly enhance static word embeddings without inheriting their computational overhead. By moving the complexity of Transformers to the training phase, researchers can produce lightweight, high-quality vectors suitable for a wide range of real-world NLP applications.

Summary updated

BibTeX
@inproceedings{gupta2021obtaining,
  author = {Prakhar Gupta and Martin Jaggi},
  title = {{Obtaining Better Static Word Embeddings Using Contextual Embedding Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.408},
}
Figure