Relative representations enable zero-shot latent space communication

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

Introduction

Neural networks trained on the same task often develop "absolute" latent spaces that look completely different due to random initialization. This paper reveals that while the coordinates change, the relative geometry—the angles and distances between data points—remains remarkably consistent. By representing data points based on their similarity to a fixed set of "anchors," the authors enable zero-shot model stitching. This breakthrough allows researchers to plug an encoder from one model into a decoder from another without any additional training.

The Challenge of Incoherent Latent Spaces

In deep learning, we often think of the "latent space" as a meaningful map of our data. However, if you train the exact same architecture on the exact same data twice, the resulting latent spaces will be "incoherent." Because of random weight initialization and stochastic training (such as shuffling data), one model might place the concept of a "dog" at coordinates $(1, 1)$ while another places it at $(-5, 10)$.

Latent spaces from different training runs

This lack of alignment makes it impossible to seamlessly reuse components. You cannot simply take a state-of-the-art image encoder and "stitch" it to your custom decoder because they speak different coordinate languages. Traditionally, fixing this required training "stitching layers" to translate between spaces. The authors ask a fundamental question: Is there a way to represent data that is naturally invariant to these random transformations?

Methods: Relative Representations

To solve this, the authors propose Relative Representations. Instead of defining a data point by its absolute coordinates in a vector space, they define it by its relationship to a set of anchors (a fixed subset of the data).

Constructing relative representations

The process works as follows:

  1. Anchor Selection: Pick a set of samples $A$ (e.g., 300 random images or words) to serve as reference points.
  2. Similarity Encoding: For any new data point $x$, calculate its similarity to every anchor in $A$ using a similarity function, specifically Cosine Similarity.
  3. The Relative Vector: The new representation of $x$ becomes a vector of these similarity scores.

Because Cosine Similarity is invariant to rotations, reflections, and uniform scaling, the relative representation remains the same even if the entire latent space is rotated or stretched by a different training run. This creates a "universal" coordinate system based on the data itself, rather than the arbitrary axes of a specific model.

Key Insights and Ideas

  • The "Rosetta Stone" of Latent Spaces: Neural networks essentially perform an isometry. They might move the "furniture" around, but the distances and angles between the pieces stay the same. Relative representations act as a Rosetta Stone, translating these different views into a single, unified language.
  • Parallel Anchors: To communicate across domains (like English to French), models can use "parallel anchors"—pairs of points that mean the same thing in different spaces (e.g., the English word "cat" and the French word "chat").
  • Zero-Shot Interoperability: This is the first work to successfully demonstrate stitching neural components from different training regimens (different seeds, different architectures) without any fine-tuning or training of translation layers.
  • Performance Proxy: The similarity between a model's relative latent space and a "reference" model's space is a high-quality predictor of model accuracy, even without using labels.

Experimental Validation and Results

The authors validated their approach across multiple modalities, including images (MNIST, CIFAR, ImageNet), text (Amazon Reviews, DBpedia), and graphs (Cora, PubMed).

  • Word Embedding Alignment: When comparing FastText and Word2Vec (two fundamentally different training methods), absolute representations had zero overlap in their nearest neighbors. By switching to relative representations, the overlap jumped significantly, and the Mean Reciprocal Rank (MRR) reached nearly 0.98, indicating the models were essentially "seeing" the same semantic clusters.
  • Model Stitching: In image reconstruction tasks, stitching an absolute encoder to a different absolute decoder resulted in gibberish. Using relative representations, the stitched models produced reconstructions nearly indistinguishable from the original, non-stitched models.
  • Cross-Lingual Success: The authors successfully used an English-trained classifier to categorize reviews in Japanese, French, and Spanish by simply passing the relative representations through parallel anchors, achieving performance far above random guessing.

Limitations and Future Work

While powerful, the method has a few limitations. The quality of the representation depends heavily on the number and choice of anchors; while random selection works well, "model collapse" can occur if too few anchors are used during end-to-end training. Additionally, calculating similarities to hundreds of anchors adds a small computational cost to the forward pass. Finally, while cosine similarity handles rotations and scaling, it does not account for more complex, non-linear warping of the latent space. Future work may explore vector quantization or alternative similarity functions to handle these noisier transformations.

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