Skip to main content
QUICK REVIEW

[Paper Review] Matryoshka Representation Learning

Aditya Kusupati, Gantavya Bhatt|arXiv (Cornell University)|May 26, 2022
Domain Adaptation and Few-Shot LearningComputer Science24 citations
TL;DR

MRL learns nested coarse-to-fine representations within a single embedding, enabling adaptive deployment with no extra inference cost and achieving large gains in efficiency (e.g., up to 14x smaller representations and up to 14x retrieval speedups) while maintaining or improving accuracy across tasks and modalities.

ABSTRACT

Learned representations are a central component in modern ML systems, serving a multitude of downstream tasks. When training such representations, it is often the case that computational and statistical constraints for each downstream task are unknown. In this context rigid, fixed capacity representations can be either over or under-accommodating to the task at hand. This leads us to ask: can we design a flexible representation that can adapt to multiple downstream tasks with varying computational resources? Our main contribution is Matryoshka Representation Learning (MRL) which encodes information at different granularities and allows a single embedding to adapt to the computational constraints of downstream tasks. MRL minimally modifies existing representation learning pipelines and imposes no additional cost during inference and deployment. MRL learns coarse-to-fine representations that are at least as accurate and rich as independently trained low-dimensional representations. The flexibility within the learned Matryoshka Representations offer: (a) up to 14x smaller embedding size for ImageNet-1K classification at the same level of accuracy; (b) up to 14x real-world speed-ups for large-scale retrieval on ImageNet-1K and 4K; and (c) up to 2% accuracy improvements for long-tail few-shot classification, all while being as robust as the original representations. Finally, we show that MRL extends seamlessly to web-scale datasets (ImageNet, JFT) across various modalities -- vision (ViT, ResNet), vision + language (ALIGN) and language (BERT). MRL code and pretrained models are open-sourced at https://github.com/RAIVNLab/MRL.

Motivation & Objective

  • Motivate flexible representations that adapt to downstream tasks with varying compute constraints.
  • Propose a single embedding that encodes multiple granularities via nested dimensions.
  • Enable near-optimal accuracy at multiple resource levels without extra deployment cost.
  • Demonstrate applicability of MRL across vision, vision+language, and language models, including web-scale data.

Proposed method

  • Define a d-dimensional representation z and a nesting set M with O(log d) sizes.
  • Train multiple linear classifiers W^{(m)} on the first m dimensions for each m in M and aggregate losses with weights c_m.
  • Optionally tie weights to reduce memory as W^{(m)} = W_{1:m} (MRL-E).
  • Adapt MRL to supervised, contrastive, and masked-language modeling frameworks with minimal changes.
  • Demonstrate coarse-to-fine representations that interpolate between optimized granularities (between m in M).
  • Provide two deployment modes: Adaptive Classification (AC) and Adaptive Retrieval (AR).

Experimental results

Research questions

  • RQ1How can a single representation support multiple downstream tasks with varying compute budgets?
  • RQ2Do coarse-to-fine nested representations retain or improve accuracy compared with independently trained low-dimensional baselines?
  • RQ3Can MRL scale to web-scale datasets and multiple modalities (vision, vision+language, language) without extra inference cost?
  • RQ4What are the practical benefits in adaptive classification and adaptive retrieval workflows?
  • RQ5How do the nested representations behave in robustness and downstream tasks such as few-shot and long-tail learning?

Key findings

  • Up to 14x smaller embedding size at the same accuracy for ImageNet-1K classification using adaptive classification with MRL.
  • Up to 14x real-world speed-ups for large-scale retrieval on ImageNet-1K and 4K while maintaining comparable accuracy.
  • Up to 2% accuracy improvements in long-tail few-shot and continual learning settings, with robustness on par with the original embeddings.
  • MRL generalizes across modalities (ResNet, ViT, ALIGN, BERT) and web-scale data (ImageNet, JFT, ALIGN).
  • Coarse-to-fine representations exhibit interpolation across dimensions, enabling flexible deployment without extra inference cost.
  • Retrieval can be effectively performed with adaptive shortlisting and reranking, leveraging nested representations for significant speedups.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.