Abstract
Dual encoder (DE) models, where a pair of matching query and document are embedded into similar vector representations, are widely used in information retrieval due to their simplicity and scalability. However, the Euclidean geometry of the embedding space limits the expressive power of DEs, which may compromise their quality. This paper investigates such limitations in the context of hierarchical retrieval (HR), where the document set has a hierarchical structure and the matching documents for a query are all of its ancestors. We first prove that DEs are feasible for HR as long as the embedding dimension is linear in the depth of the hierarchy and logarithmic in the number of documents. Then we study the problem of learning such embeddings in a standard retrieval setup where DEs are trained on samples of matching query and document pairs. Our experiments reveal a lost-in-the-long-distance phenomenon, where retrieval accuracy degrades for documents further away in the hierarchy. To address this, we introduce a pretrain-finetune recipe that significantly improves long-distance retrieval without sacrificing performance on closer documents. We experiment on a realistic hierarchy from WordNet for retrieving documents at various levels of abstraction, and show that pretrain-finetune boosts the recall on long-distance pairs from 19% to 76%. Finally, we demonstrate that our method improves retrieval of relevant products on a shopping queries dataset.
Introduction
Most modern search engines and recommendation systems rely on Dual Encoders (DEs). These models map queries and documents into a shared vector space, allowing for efficient retrieval via nearest-neighbor search. While DEs excel at finding exact or near-exact matches, they often struggle with Hierarchical Retrieval (HR).
In HR, a query should retrieve not only the most specific relevant document but also its broader semantic ancestors. For instance, a search for "kid's sandals" should ideally surface the specific product as well as broader categories like "Sandals," "Kid's shoes," and "Footwear."
Theoretical Foundations: Is Euclidean Space Sufficient?
A common intuition in machine learning is that hierarchical data, which grows exponentially with depth, requires hyperbolic geometry to be represented efficiently. However, this research provides a constructive proof that asymmetric Euclidean DEs (where query and document encoders differ) are mathematically sufficient for HR. The authors demonstrate that the required embedding dimension $d$ scales linearly with the depth of the hierarchy and only logarithmic with the total number of documents. This suggests that the failures of current models are not due to the geometry itself, but rather how we train them.
The "Lost-in-the-Long-Distance" Phenomenon
Despite the theoretical feasibility, standard training methods fail to capture long-distance relationships in a hierarchy. The authors identify a specific failure mode termed the "lost-in-the-long-distance" phenomenon: as documents become more abstract (further from the query in the hierarchy), retrieval accuracy drops precipitously.
In standard joint training, the model faces a "tug-of-war." To accurately retrieve distant ancestors, it often has to sacrifice the precision of close-range matches. Most models end up prioritizing the "easy" short-distance matches, leaving the long-distance recall at a mere fraction of its potential.
The Pretrain-Finetune Recipe
To overcome this barrier, the researchers propose a two-stage training curriculum that avoids the pitfalls of joint optimization:
- Pretraining: The DE is first trained on a standard dataset consisting primarily of short-distance or exact matches. This establishes a solid baseline for specific retrieval.
- Finetuning: The model is then specifically trained on long-distance pairs (ancestors further up the tree).
Crucially, the authors found that successful finetuning requires two specific adjustments: increasing the softmax temperature and lowering the learning rate. This allows the model to "stretch" its existing representations to encompass broad categories without collapsing the specific distinctions learned during pretraining.
Empirical Results
The effectiveness of this recipe was validated across several benchmarks:
- WordNet: In a hierarchy of over 82,000 noun concepts, standard training achieved only 19.4% recall for documents at a distance of 8 (the most abstract ancestors). The pretrain-finetune recipe increased this to 75.7%. Overall recall across all levels improved from 71.4% to 92.3%.
- ESCI (Amazon Shopping Queries): On a dataset of 2.6 million query-product pairs, the recipe outperformed naive joint training for both "Exact" matches and "Substitute" (more abstract) matches, demonstrating real-world utility for commercial search.
Conclusion
This work demonstrates that the limitations of Dual Encoders in hierarchical retrieval are primarily an optimization challenge rather than a geometric one. By adopting a sequential pretrain-finetune approach, practitioners can significantly improve the retrieval of abstract, high-level information without compromising the accuracy of specific results. Future work will explore applying this recipe to scenarios where the underlying hierarchy is not explicitly labeled but must be discovered from raw data.
Summary updated