Relative representations enable zero-shot latent space communication

Luca Moschella, Valentino Maiorca, Marco Fumero, Antonio Norelli, Francesco Locatello, Emanuele Rodolà

Introduction

Deep learning models typically represent data in a high-dimensional "latent space." While these spaces capture semantic relationships, they are notoriously unstable. Training the same architecture twice on identical data with different random seeds results in "incoherent" latent spaces—one might be rotated, scaled, or reflected relative to the other. This incoherence prevents the direct reuse or "stitching" of components (e.g., using Encoder A with Decoder B) without costly retraining of alignment layers.

The Problem of Incoherent Latent Spaces

The instability of absolute coordinate systems in neural networks is a fundamental barrier to modularity. As shown in the figure below, independent training runs produce distinct geometric arrangements of the same data classes, even when the underlying semantic structure is identical.

Latent space visualizations across four independent training runs (Train 1-4). While the absolute coordinates vary due to random initialization, the relative semantic clusters remain consistent.

Methods: Relative Representations via Anchor Projection

To overcome this, the authors propose shifting from absolute coordinates to relative representations. Instead of defining a point $x$ by its raw vector output, it is defined by its relationship to a set of fixed "anchors" ($a_1, a_2, ..., a_k$).

  1. Anchor Selection: A subset of data points is chosen to serve as reference anchors. These can be from the training set or even out-of-distribution data.
  2. Similarity Projection: Each sample is represented as a vector of cosine similarities to these anchors: $r(x) = [sim(x, a_1), ..., sim(x, a_k)]$.
  3. Invariance: Because cosine similarity is invariant to rotations, reflections, and isotropic scaling, the resulting representation $r(x)$ remains stable across different models that have learned the same underlying semantic structure.
Conceptual diagram of the relative representation process. A sample (blue dot) is projected into a relative space based on its similarity to a set of fixed anchors (stars).

Experimental Validation

The authors validated their approach across a massive variety of modalities, including images (MNIST, CIFAR, ImageNet), text (Amazon Reviews, WikiMatrix), and graphs (Cora, PubMed).

Zero-Shot Model Stitching

The primary breakthrough is the ability to perform zero-shot model stitching. By using relative representations, an encoder from one model can be plugged directly into the decoder of another without any additional training or fine-tuning.

  • Word Embeddings: Aligning FastText and Word2Vec achieved a Mean Reciprocal Rank (MRR) of 0.94 to 0.98, compared to zero overlap using absolute coordinates.
  • Image Reconstruction: In Autoencoder stitching, relative representations reduced Mean Squared Error (MSE) by up to two orders of magnitude. Stitched models produced recognizable images, while absolute ones produced noise.
  • Cross-Architecture: The method even allowed stitching a RexNet-100 decoder to Vision Transformer (ViT) encoders on ImageNet, maintaining an F1 score of ~72% despite the radical difference in architectures.

Key Insights and Limitations

The core finding is that neural networks naturally converge to a similar "semantic manifold" regardless of initialization. Relative representations provide a "universal language" for these manifolds, enabling communication between models "out of the box."

However, the method has limitations:

  • Anchor Selection: Performance depends on the number and quality of anchors; the authors found that 300–700 anchors usually suffice, but optimal selection remains an open question.
  • Computational Cost: Calculating similarities against anchors adds computational overhead to every forward pass.
  • Non-Linear Warping: While invariant to linear transformations, the method may struggle with complex non-linear distortions between latent spaces. Future work may explore geodesic distances to handle these cases.

Summary updated

BibTeX
@inproceedings{moschella2023relative,
  author = {Luca Moschella and Valentino Maiorca and Marco Fumero and Antonio Norelli and Francesco Locatello and Emanuele Rodolà},
  title = {{Relative representations enable zero-shot latent space communication}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=SrC-nwieGJ},
}
Figure