Artificial Intelligence 23 min read

Tree‑based Deep Match (TDM): Design, Implementation, and Applications in Large‑Scale Retrieval

This article presents a comprehensive overview of the Tree‑based Deep Match (TDM) algorithm, describing the evolution of retrieval technology, the limitations of traditional Match‑Rank pipelines, the design of a one‑stage tree‑indexed deep matching model, its training methodology, performance gains on public datasets, and its deployment in Alibaba’s advertising and e‑commerce platforms.

DataFunTalk
DataFunTalk
DataFunTalk
Tree‑based Deep Match (TDM): Design, Implementation, and Applications in Large‑Scale Retrieval

Guest Speaker: He Jie, Senior Algorithm Expert, Alibaba Mama

Editor: Sun Kai

Source: DataFun AI Talk

Community: DataFun

Note: Reprints are welcome with proper attribution.

Introduction: Alibaba Mama, the digital‑marketing platform of Alibaba Group, generated over 150 billion CNY in ad revenue in 2018, accounting for roughly half of China’s advertising market. To keep this commercial “aircraft” moving, the technical team follows a strategy of technology‑driven business growth, and the Tree‑based Deep Match (TDM) algorithm is a flagship example of this approach.

The talk is divided into four parts:

Current status of retrieval technology from the perspective of Internet recommendation.

Design principles and concrete implementation of Deep Tree Retrieval (TDM).

Application of TDM to online business scenarios.

Future thoughts on the next generation of retrieval technology.

1. Retrieval Technology Landscape

Retrieval is the common foundation for recommendation, search, and advertising. It can be uniformly defined as selecting items of interest to users from the whole item pool. The key difference lies in how user intent is expressed: explicit queries in search, implicit behavior in recommendation, and bid‑adjusted relevance in advertising.

Historically, when data volume was small, a simple algorithm could scan the entire candidate set in one pass. As data exploded—especially with the rise of mobile internet—the candidate set grew to billions, making one‑pass methods infeasible.

To cope with limited compute, the industry adopted a two‑stage Match + Rank pipeline: a fast Match stage narrows the candidate set, followed by a more expensive Rank stage that orders the remaining items. This architecture became the mainstream.

With the advent of GPU‑accelerated heterogeneous computing, the question arose: can we move beyond the staged pipeline and design an end‑to‑end retrieval system? This is the motivation behind TDM.

2. From Match to One‑Stage Retrieval

In the first stage, Match must efficiently retrieve the top‑K relevant items from a massive candidate pool (e.g., billions of products). Classic two‑stage implementations are also two‑step: User → Query‑rewrite → Document for search, or User → Interest‑tag → Item for recommendation.

These two‑step designs suffer from isolated optimization; improvements in one step do not propagate to the other, and label truncation at each stage limits recall.

One‑stage full‑library retrieval, inspired by vector‑based image search (e.g., FAISS), learns item embeddings and performs nearest‑neighbor search via product quantization (PQ). While this improves recall, the simple inner‑product model has limited capacity, and the indexing objective (minimizing quantization error) does not align with the retrieval objective (maximizing top‑K recall).

Thus, retrieval technology is a fusion of model capability and index efficiency.

Item‑CF: heuristic, non‑learned, two‑stage index.

Inner‑product vector retrieval: simple model, full‑library one‑stage index, but limited performance.

Future directions require more powerful models combined with more efficient indexes.

3. Design Principles of TDM

TDM adopts a tree‑structured index. A 30‑level binary tree can retrieve the top‑1 item with only 30 computations, making it highly scalable for billions of items.

The core challenges addressed are:

How to achieve efficient tree‑based retrieval?

How to model user interest so that the tree search remains effective?

How to learn the interest model?

How to construct and optimize the tree index?

BeamSearch is used to traverse the tree top‑down, keeping the best K nodes at each level. The complexity is O(2·K·log₂N), where N is the number of leaf items.

To guarantee BeamSearch effectiveness, a “max‑heap tree” is defined: the interest score of a parent node equals the maximum score among its children (optionally normalized). This property ensures that the top‑K parents of a layer contain the ancestors of the top‑K leaves.

Training proceeds by constructing positive and negative samples for each node. Leaf‑level samples are derived from user click / non‑click behavior; higher‑level samples are obtained by propagating positive labels upward and performing negative sampling at each level. The ranking problem is transformed into a multi‑class classification task, and negative sampling with NCE approximates the softmax.

The model architecture uses multi‑layer attention‑based deep networks to capture multi‑peak user interests, achieving a 16 % F1 improvement. Hierarchical representation of temporal features adds another 18 % gain.

The tree structure directly influences both indexing efficiency and the distribution of training samples; a well‑designed tree raises the upper bound of model performance.

Joint optimization of model parameters θ and the mapping function π (which assigns items to leaf nodes) is performed via an alternating algorithm. π optimization is a weighted bipartite matching problem (O(n³)), approximated by a greedy algorithm (Algorithm 2), yielding an additional ~10 % F1 boost.

4. Online Applications and Business Impact

TDM has been deployed in Alibaba Mama’s targeted‑ad matching stage, covering Shop/Node/Item pipelines and serving the majority of traffic. Click‑through‑rate (CTR) and revenue‑per‑thousand‑impressions (RPM) have both increased by double‑digit percentages.

Latency was initially a concern (≈60 ms RT), but after system‑level optimizations the online overhead became negligible.

Open‑source code for offline training and online serving is available on GitHub:

Training: https://github.com/alibaba/x-deeplearning/wiki/深度树匹配模型(TDM)

Serving: https://github.com/alibaba/x-deeplearning/wiki/TDMServing

Future work includes extending TDM to other domains such as graph retrieval and search, improving interpretability, and building a one‑stop platform (DIMO → DISO) for automated data‑to‑model‑to‑service pipelines.

In summary, TDM breaks the traditional Match + Rank constraint by jointly optimizing a deep learning model and a tree‑based index, achieving end‑to‑end retrieval with high efficiency and strong performance, and it is poised to become a universal backbone for search, recommendation, and advertising systems.

For questions, contact He Jie at [email protected] . Recruitment for Alibaba Mama’s algorithm team is ongoing.

END

deep learningrecommendation systemsLarge Scaleretrievaltree indexingTDM
DataFunTalk
Written by

DataFunTalk

Dedicated to sharing and discussing big data and AI technology applications, aiming to empower a million data scientists. Regularly hosts live tech talks and curates articles on big data, recommendation/search algorithms, advertising algorithms, NLP, intelligent risk control, autonomous driving, and machine learning/deep learning.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.