NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Contrastive Loss is All You Need to Recover Analogies as Parallel Lines

Narutatsu Ri, Fei-Tzin Lee, Nakul Verma

TL;DR

This paper introduces a simple contrastive learning approach for word embeddings that matches the performance of complex models on analogy tasks, but trains significantly faster. Crucially, it provides a theoretical explanation for why these embeddings form parallel line structures, linking it directly to word co-occurrence statistics.

What Problem Does This Paper Address?

Word embeddings, like those used in natural language processing (NLP), represent words as vectors in a high-dimensional space. A fascinating property observed in these embeddings is their ability to capture linguistic analogies (e.g., "king" - "man" + "woman" ≈ "queen") through geometric structures, often described as parallelograms or, more recently, as parallel lines. While this phenomenon has been empirically observed, the underlying mechanism driving it has remained largely a mystery. This paper aims to demystify this by proposing a simple, efficient method and providing a theoretical framework that explains how these parallel structures emerge.

Methods

The core of the paper is the Contrastive Word Model (CWM). It's based on the general principle of contrastive learning: pull similar items closer together and push dissimilar items apart. In CWM, this translates to:

  • Pushing: Words that do not co-occur are pushed away from each other in the embedding space.
  • Pulling: Words that do co-occur are pulled closer together.

This is achieved through a specific "push-pull" objective function that uses a hinge loss. The authors then provide a theoretical analysis (Theorem 1) showing that this contrastive objective, when applied to word co-occurrence statistics, is sufficient to generate parallel line structures for analogy quadruples. They establish a precise mathematical relationship between the co-occurrence statistics of word pairs and the resulting geometric structure (parallelogram vs. trapezoid).

Datasets

  • Training: The authors used the "03/2023 version of Wikimedia Downloads dump" for training their models.
  • Evaluation: The BATS analogy dataset (Gladkova et al., 2016) was used for analogy recovery tasks. For word similarity tasks, they used WordSim353, MEN Test Collection, and SimLex999.

Key Insights and Ideas

  • Simplicity is Powerful: A basic contrastive learning objective, focused solely on co-occurrence statistics, can achieve state-of-the-art performance on analogy tasks, outperforming more complex, established methods.
  • Speed Matters: CWM offers a dramatic speedup (up to 50x) in training time compared to popular word embedding models like Skip-gram and GloVe, making it much more practical.
  • Geometric Structure Explained: The paper provides a theoretical link between word co-occurrence statistics and the geometric representation of analogies as parallel lines. This is a significant step towards understanding why word embeddings behave this way.
  • Co-occurrence is Key: The theoretical analysis reveals that the specific patterns of word co-occurrences in a corpus directly dictate whether analogies will be represented as parallelograms or trapezoids.
  • "Ambiguous" Analogies: The study also touches upon how the strength of the co-occurrence relationship (quantified by a value called 'ζ') correlates with the clarity of analogies, suggesting that weaker relationships lead to less defined geometric structures.

Key Results

  • Analogy Recovery: CWM achieved competitive performance on analogy recovery tasks, even outperforming Skip-gram and GloVe on the Mean Similarity Measure (MSM) by 7%.
  • Training Speed: CWM achieved a 50x speedup in training time compared to SGNS (Skip-gram with negative sampling).
  • Geometric Structure Validation: The theoretical predictions about parallelogram and trapezoid structures based on the value of 'ζ' were empirically validated, with 87% of quadruples forming parallelograms when 'ζ' ≈ 1 and 86% forming trapezoids when 'ζ' ≠ 1.
  • Word Similarity: CWM performed comparably to existing models on word similarity benchmarks.

Limitations and Future Work

  • Necessity vs. Sufficiency: While the paper demonstrates that the contrastive push-pull mechanism is sufficient to recover analogies as parallel lines, it remains an open question whether it is a necessary condition. Investigating other mechanisms that might achieve similar results is suggested.
  • Further Refinement: The authors believe further refinement of the CWM model is needed to boost performance on various downstream tasks, despite its strong performance on analogy and similarity benchmarks.
  • Ambiguity in Analogies: The paper hints at the complexity of "ambiguous" analogies and suggests further investigation into how these ambiguities correlate with embedding geometry.

Summary updated

BibTeX
@inproceedings{ri2023contrastive,
  author = {Narutatsu Ri and Fei-Tzin Lee and Nakul Verma},
  title = {{Contrastive Loss is All You Need to Recover Analogies as Parallel Lines}},
  booktitle = {RepL4NLP @ ACL},
  year = {2023},
  url = {https://openreview.net/forum?id=YGCj9tyGIq},
}
Figure