eamid/trimap

TriMap: Large-scale Dimensionality Reduction Using Triplets

What it solves

TriMap addresses the challenge of dimensionality reduction—converting high-dimensional data into a low-dimensional embedding (typically 2D or 3D)—while preserving the global structure of the data. Unlike methods like t-SNE or UMAP, which often prioritize local clusters, TriMap aims to better reflect relative distances between clusters, multiple scales of data, and the presence of outliers.

How it works

TriMap uses triplet constraints to create embeddings. A triplet constraint takes the form: "point i is closer to point j than point k." These triplets are sampled from the high-dimensional representation of the data, and a weighting scheme is applied to determine the importance of each triplet. The system optimizes the embedding to satisfy these constraints using gradient descent.

Who it’s for

It is designed for data scientists and researchers who need to visualize high-dimensional datasets (such as CNN features or genomic data) and require a more accurate global view of the data's structure than traditional methods provide.

Highlights

  • Global Structure Preservation: Specifically designed to maintain the relative distances of clusters and identify outliers.
  • Multiple Implementations: Available as a legacy NumPy/Numba version and a GPU-parallel PyTorch version (TorchTRIMAP) for faster processing on CUDA, MPS, and CPU.
  • Flexible Backends: The PyTorch version supports various k-NN backends including exact PyTorch search, Faiss (flat and IVF), and NVIDIA cuVS CAGRA for very large datasets.
  • Scikit-learn Compatible: Uses a transformer API (fit_transform) similar to standard sklearn libraries for ease of integration.

Related

  • Project
  • Project
  • Project
  • Project
  • Project