Obtaining Better Static Word Embeddings Using Contextual Embedding Models

Prakhar Gupta, Martin Jaggi

Introduction

Modern Natural Language Processing (NLP) faces a significant trade-off between the high performance of massive contextual models (Transformers) and the efficiency of traditional static word embeddings. While contextual models like BERT and GPT-2 excel at understanding nuanced meanings, they are computationally expensive and slow, making them unsuitable for low-resource devices or latency-sensitive applications. Conversely, static embeddings like Word2Vec or GloVe are fast and interpretable but lack contextual depth. This paper introduces X2STATIC, a framework designed to distill the semantic richness of contextual models into high-performing, efficient static word vectors.

Methods: The Distillation Framework

The researchers propose a distillation method based on the Continuous Bag of Words (CBOW) architecture. In standard CBOW, a target word is predicted from the average of its surrounding word vectors. X2STATIC replaces this simple average with the output of a pre-trained contextual "teacher" model.

Two primary variants were developed:

  1. X2STATIC$_{sent}$: The context for a target word is derived from the average contextual embeddings of all words in its sentence.
  2. X2STATIC$_{para}$: To enhance efficiency, contextual embeddings are extracted from entire paragraphs. This allows the heavy teacher model to run once per paragraph, capturing broader semantic themes while reducing computational overhead during the training phase.

By training a static embedding matrix to predict words based on these sophisticated teacher contexts, the resulting vectors "absorb" the complex relationships learned by the Transformer.

Key Insights and Ideas

Scaling and Data Efficiency

A critical advantage of the X2STATIC approach is its ability to scale. Unlike previous distillation methods, such as ASE, which often plateau as more data is introduced, X2STATIC models show consistent performance gains as the training corpus size increases. This makes the framework suitable for training on massive, web-scale datasets.

Scaling performance of X2STATIC models on SIMLEX-999 and RW-2034 as a function of training data size.

The Impact of Broader Context

Surprisingly, using paragraphs as context (X2STATIC$_{para}$) frequently outperformed sentence-level context (X2STATIC$_{sent}$). This suggests that the thematic consistency provided by a paragraph helps the model learn more robust and representative word vectors. Furthermore, the method is model-agnostic; the researchers successfully distilled knowledge from BERT, RoBERTa, and GPT-2, demonstrating consistent quality gains across different teacher architectures.

Key Results

The distilled models significantly outperform traditional baselines and previous state-of-the-art distillation techniques across multiple benchmarks.

Performance comparison of distilled static embeddings against pre-trained and baseline models across various word similarity benchmarks.

On the SimLex-999 (SL-999) benchmark, which measures true semantic similarity, BERT2STATIC$_{para}$ achieved a Spearman's $\rho$ of 0.5384, surpassing both the best previous distillation method (0.5216) and standard Sent2Vec (0.5034). In downstream supervised tasks, such as the SST-5 sentiment analysis, GPT2-STATIC$_{para}$ reached an F1 score of 16.2%, outperforming FastText (13.9%) and GloVe (15.5%).

Crucially, these performance gains come with extreme efficiency. Using X2STATIC embeddings at inference time is estimated to be tens of millions of times computationally cheaper than running a full BERT-base model, making them ideal for edge computing and high-throughput applications.

Limitations and Future Work

While X2STATIC represents a significant step forward, some limitations remain. The researchers utilized a "one-size-fits-all" hyperparameter setting, suggesting that further optimization could yield even better results. Additionally, as static embeddings, these models still struggle with extreme polysemy (homonyms), though they handle general semantics far better than their predecessors. Future research may explore extending this framework to cross-lingual domains or developing "sense embeddings" to better address words with multiple distinct meanings.

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