Connecting Neural Models Latent Geometries with Relative Geodesic Representations

Hanlin Yu, Berfin Inal, Marco Fumero · DOI

Abstract

Neural networks trained on similar data often learn disparate latent spaces, hindering model interoperability and comparison. We present "relative geodesic representations," a novel framework that aligns these distinct spaces by measuring intrinsic geometric distances to a set of anchor points. By approximating complex geodesic paths with straight-line Riemannian energies, our method enables efficient, zero-shot stitching of diverse architectures—including ResNets, Vision Transformers, and autoencoders—without requiring additional fine-tuning or adapter training.

Introduction

Deep learning models typically map high-dimensional inputs into lower-dimensional latent spaces. However, variations in architecture (e.g., CNNs vs. Transformers) or random initialization lead to entirely different latent coordinate systems, even for models trained on identical datasets for the same task. This lack of alignment makes it difficult to "stitch" models together, such as plugging an encoder from one model into the decoder of another.

Previous attempts at "relative representations" utilized cosine similarity to bypass this issue. However, cosine similarity only accounts for angle-preserving transformations. We argue that different models learn different parameterizations of the same underlying data manifold. To accurately translate between these spaces, we require a distance metric that respects the intrinsic, curved geometry of that manifold.

Methodology

Conceptual overview of relative geodesic representations aligning two latent spaces $\mathcal{Z}_1$ and $\mathcal{Z}_2$ via anchor points and geodesic paths.

The core of our approach is the Relative Geodesic Representation. Instead of Euclidean or cosine distances, we measure the geodesic distance—the shortest path along the curved manifold—between data points and a fixed set of anchor points in the latent space. To implement this efficiently, we rely on two key techniques:

  1. The Pullback Metric: Since the geometry of an abstract latent space is difficult to define directly, we use a "pullback metric." This mathematical tool projects the well-understood geometry of a model's output space (such as reconstructed image pixels or classification probabilities) backward into the latent space.
  2. Straight-Line Approximation: Calculating exact geodesic paths on a manifold is computationally intensive. We bypass this by approximating the geodesic distance using the Riemannian energy of a straight line connecting two points in the latent space. This requires only a few discretized forward passes through the decoder and scales efficiently to large-scale models.

For discriminative foundation models lacking a decoder, we propose pulling back metrics from either a standard classification head (RelGeo(L2)) or a self-supervised instance discrimination head (RelGeo(Diet)).

Key Insights and Empirical Evidence

Comparison between approximate straight-line energies and true geodesic energies, showing high correlation across different datasets.

A significant finding of this work is that straight-line energy approximations correlate almost perfectly (Spearman $\rho > 0.99$) with true, computationally expensive geodesic energies. This suggests that the benefits of Riemannian geometry can be realized without exhaustive path optimization.

Furthermore, the success of this method provides strong empirical evidence for the Manifold Hypothesis: different neural networks appear to converge on the same underlying geometric reality of the data, merely viewing it through different coordinate systems. By pulling back metrics from specific output heads, we can tailor the latent space geometry: classification heads emphasize semantic class boundaries, while instance discriminators preserve strict identity.

Experimental Results

  • Autoencoders: The method achieved near-perfect latent space alignment and zero-shot model stitching using only 5 anchor points. It vastly outperformed linear, orthogonal, and cosine-based baselines, producing visually flawless reconstructions when swapping encoders and decoders between differently initialized models.
  • Vision Foundation Models: Evaluated across ResNet-50, ViTs, and DINOv2, the instance discrimination metric (RelGeo(Diet)) more than doubled retrieval performance on ImageNet-1k compared to the cosine baseline (Mean Reciprocal Rank of 0.566 vs 0.221).
  • Zero-Shot Stitching: Using the classification metric (RelGeo(L2)) achieved superior zero-shot stitching accuracy across architectures, reaching 95.5% on CIFAR-10 compared to 90.7% for the baseline.
  • Multimodal Alignment: The framework successfully aligned vision models with CLIP text encoders on the Flickr30k dataset without any cross-modal training, significantly improving upon previous relative representation techniques.

Conclusion and Future Work

Relative geodesic representations provide a robust, training-free method for aligning disparate neural latent spaces. While the straight-line approximation is highly effective, it can break down in regions of high curvature, typically associated with out-of-distribution samples. Future research will explore non-linear paths, such as K-Nearest Neighbor (KNN) graphs in the latent space, to ensure distance approximations remain on the dense portions of the data manifold. Additionally, we aim to further investigate the potential of this technique for zero-training multimodal alignment.

Summary updated

BibTeX
@inproceedings{yu2025connecting,
  author = {Hanlin Yu and Berfin Inal and Marco Fumero},
  title = {{Connecting Neural Models Latent Geometries with Relative Geodesic Representations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=4JnZvkVssS},
}
Figure