EHI: End-to-end Learning of Hierarchical Index for Efficient Dense Retrieval

Ramnath Kumar, Anshul Mittal, Nilesh Gupta, Aditya Kusupati, Inderjit Dhillon, Prateek Jain

TL;DR

EHI (End-to-end Hierarchical Indexing) fundamentally shifts the dense retrieval paradigm by jointly optimizing the embedding encoder and the approximate nearest neighbor search (ANNS) index in a single pipeline. By introducing differentiable "dense path embeddings," EHI successfully trains an inverted file index (IVF)-style tree structure from scratch, delivering significant gains in both retrieval accuracy and search efficiency.

What Problem Does This Paper Address?

Modern semantic search systems typically rely on a two-stage dense retrieval process: first, a dual encoder is trained using contrastive learning to map queries and documents into a shared embedding space; second, an off-the-shelf Approximate Nearest Neighbor Search (ANNS) library (like ScaNN or Faiss) indexes these embeddings offline for fast runtime retrieval.

The authors identify two major flaws in this disjointed approach:

  1. Embedding-ANNS Misalignment: Because the encoder is completely unaware of the downstream indexing mechanism, the learned embedding space often conflicts with the geometric requirements of the ANNS clustering structure. This leads to unnatural splitting or merging of semantic clusters.
  2. Disregard for Query Distribution: Standard ANNS indexers cluster documents globally and uniformly. They fail to account for real-world query distributions, meaning they don't optimize the index structure to handle highly frequent "head" queries differently from rare "tail" queries.

EHI solves this by unifying embedding learning and index structure optimization into a single, end-to-end trainable framework.

Figure 1: Motivation of EHI.

Methods

The core challenge of end-to-end index learning is that routing data through a tree structure is inherently discrete and non-differentiable. EHI bypasses this bottleneck by introducing dense path embeddings.

Instead of hard-routing a document or query to a single branch, EHI models the traversal path as a concatenated vector of conditional probability distributions across the children nodes at each height of a $k$-ary tree. This mathematical formulation makes the tree traversal differentiable.

Overview of the EHI framework, illustrating how queries and documents generate both dense text representations and differentiable path embeddings through the hierarchical indexer tree.

EHI jointly trains a shared DistilBERT encoder and the indexer parameters using a multi-task loss function composed of three distinct objectives:

  • Semantic Similarity Loss ($L_{siamese}$): Standard contrastive loss ensuring that relevant query-document embedding pairs are close to each other.
  • Indexing Similarity Loss ($L_{indexing}$): A contrastive loss applied directly to the path embeddings, forcing relevant queries and documents to traverse the exact same paths through the index tree.
  • Intra-leaf Similarity Loss ($L_{intra-leaf}$): A specialized triplet loss that spreads out semantically irrelevant documents that happen to land within the same leaf node.

Datasets

The authors evaluated EHI across several standard and diverse information retrieval benchmarks:

  • MS MARCO (Dev set): A massive, real-world web search dataset curated from Microsoft Bing containing ~9 million documents.
  • TREC DL19: A deeply judged subset of MS MARCO used for high-precision evaluation.
  • NQ320k: A subset of the Natural Questions dataset, primarily used to benchmark against generative retrieval methods.
  • SciFact & FiQA: Smaller, domain-specific datasets (scientific claims and financial QA) used to demonstrate EHI's robustness across varying corpus scales.

Key Insights and Ideas

  • The Power of Joint Optimization: By forcing the encoder to be "index-aware," the model learns representations that naturally cluster into the available tree slots, eliminating the accuracy drop typically seen when moving from exact search to approximate search.
  • Query-Aware Load Balancing: EHI naturally adapts to query popularity. It learns to create finer-grained, highly isolated clusters for popular query domains, which dramatically reduces the average number of documents the system needs to visit during inference.
  • "Free" Hard Negative Mining: Because the index structure is updated dynamically at every training iteration, EHI can perform hard negative mining directly from the indexed leaf nodes of a query without needing to asynchronously rebuild a global index.

Key Results

EHI demonstrates a highly compelling efficiency-accuracy trade-off compared to traditional disjoint pipelines (Dual Encoder + ScaNN/Faiss) and newer Generative Retrieval architectures (like DSI and NCI).

  • MS MARCO & TREC DL19: Under identical compute budgets, EHI outperforms existing state-of-the-art methods by +1.45% in MRR@10 on MS MARCO and +8.2% in nDCG@10 on TREC DL19.
  • Latency Reduction: On MS MARCO, EHI matches or exceeds the accuracy of an exact brute-force search while visiting 80% fewer documents. It achieves similar success on NQ320k with a 60% reduction in latency.
EHI significantly outperforms traditional DE + ScaNN/Faiss pipelines, maintaining high accuracy even when restricted to searching a tiny fraction of the document corpus.
  • Vs. Generative Retrieval: On the NQ320k dataset, EHI beats the state-of-the-art Neural Corpus Indexer (NCI) by 0.6% on Recall@10 and 1.8% on Recall@100, despite NCI utilizing a $10\times$ larger encoder model.

Limitations and Future Work

While EHI marks a significant milestone for end-to-end retrieval, the authors note a few areas for improvement:

  • Theoretical Foundations: The success of dense path embeddings is heavily empirical; a deeper theoretical understanding and formal convergence guarantees for learning discrete structures this way are still needed.
  • Billion-Scale Empirical Validation: Although the paper provides strong sublinear complexity arguments for scaling EHI to deeper trees, the current experiments max out at the 10-million document mark (MS MARCO). Testing on true billion-scale production datasets remains future work.
  • Advanced Representations: The authors suggest exploring the integration of EHI with multi-vector late interaction models (like ColBERT) or Matryoshka Embeddings to push exact search boundaries even further.

Summary updated

BibTeX
@misc{kumar2023ehi,
  author = {Ramnath Kumar and Anshul Mittal and Nilesh Gupta and Aditya Kusupati and Inderjit Dhillon and Prateek Jain},
  title = {{EHI: End-to-end Learning of Hierarchical Index for Efficient Dense Retrieval}},
  year = {2023},
  eprint = {2310.08891},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.08891},
}
Figure