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

Dimension-Accuracy Tradeoffs in Contrastive Embeddings for Triplets, Terminals & Top-k Nearest Neighbors

Vaggos Chatziafratis, Piotr Indyk

Abstract

In many machine learning applications, such as recommendation systems and search, the relative ranking of items is more critical than their absolute distances. This paper investigates the fundamental limits of ordinal embeddings—representations that preserve the relative order of distances rather than their absolute values. We establish that exactly preserving all triplet comparisons requires a dimensionality that scales linearly with the number of points ($n/2$). Furthermore, we provide tight bounds for specialized scenarios, including terminal embeddings and top-$k$ nearest neighbor preservation, revealing a nearly tight tradeoff between dimensionality and ordinal relaxation.

Introduction

Traditional metric embeddings, exemplified by the Johnson-Lindenstrauss lemma, focus on preserving absolute distances within a certain distortion factor. However, in fields like psychometrics and preference modeling, data is often inherently ordinal. For instance, a user may easily identify that they prefer Movie A over Movie B, but cannot quantify the "distance" between them in a metric space.

This paper addresses the fundamental question: How many dimensions are required to represent $n$ items such that their relative distance orderings are preserved? The authors specifically analyze three regimes:

  1. Triplets: Preserving all comparisons of the form $\text{dist}(i, j) < \text{dist}(i, k)$.
  2. Terminals: Preserving distance orders from a subset of $k$ "terminal" points to all other points in the dataset.
  3. Top-$k$ Nearest Neighbors: Preserving the relative order of the $k$ closest neighbors for every point.

Methodology

The paper is primarily theoretical, utilizing tools from discrete geometry and algebraic topology to prove lower and upper bounds.

Counting Sign Patterns

To establish lower bounds on dimensionality, the authors treat the embedding as a system of degree-2 polynomials. By applying a classic result from algebraic geometry regarding the number of "sign patterns" a set of polynomials can produce, the authors demonstrate that if the dimension $d$ is too low, there simply aren't enough possible configurations to represent all valid distance orderings.

High-Girth Graphs

To study "ordinal relaxation"—the non-metric equivalent of distortion—the authors construct specific metric spaces using high-girth graphs. By randomly sampling edges, they create distinct metric spaces that are "far apart" in terms of their triplet orderings, proving that any low-dimensional embedding must inevitably fail to preserve these relationships.

Explicit Construction for Terminals

For the terminal scenario, the authors provide a direct algorithm. They map terminals to the axes of a $k$-dimensional space (scaled by a very large factor) and map the remaining points based on their distance ranks relative to those terminals.

Key Results and Insights

The High Cost of Order

A surprising finding of this research is that preserving order is not necessarily "easier" than preserving distance. For triplet embeddings, the required dimension $d$ must be at least $n/(2+\kappa)$ for any constant $\kappa > 0$. Since $n-1$ dimensions always suffice for any $n$ points, this bound is nearly tight, showing that linear dimensionality is a fundamental requirement for exact triplet preservation.

Terminal and Top-$k$ Efficiency

The paper provides a more optimistic outlook for localized or hub-and-spoke data architectures. If the goal is to preserve distance orders from $k$ specific terminals (e.g., central servers) to the rest of the dataset, $k$ dimensions are both necessary and sufficient. Similarly, to preserve the relative order of the $k$ nearest neighbors for every point, the required dimension must grow as $\Omega(k)$.

Ordinal Relaxation Tradeoffs

In metric embeddings, we discuss "distortion" (how much a distance stretches). Here, the authors focus on "ordinal relaxation"—the maximum ratio between two distances whose relative order was flipped by the embedding. They prove that for any dimension $d$, there exists a dataset where the ordinal relaxation is at least: $$\Omega\left(\frac{\log n}{\log d + \log \log n}\right)$$

Discussion and Future Work

While this work establishes tight bounds for sublinear terminals ($k = o(n)$), a small gap remains between the upper and lower bounds when the number of terminals is a linear fraction of the total points ($k = \lambda n$). Additionally, while the polynomial sign-pattern method extends to various $\ell_p$ norms, the specific tradeoffs for non-Euclidean spaces remain an open area for exploration. Finally, the transition from theoretical existence to practical, noise-robust optimization algorithms (such as specialized versions of Stochastic Gradient Descent) is a natural next step for applying these limits to real-world datasets.

Summary updated

BibTeX
@inproceedings{chatziafratis2024dimension,
  author = {Vaggos Chatziafratis and Piotr Indyk},
  title = {{Dimension-Accuracy Tradeoffs in Contrastive Embeddings for Triplets, Terminals \& Top-k Nearest Neighbors}},
  booktitle = {SOSA},
  year = {2024},
  url = {https://openreview.net/forum?id=Etzb5xY8r3},
}

Loading related content...

Figure