BST
BST (Behavior Sequence Transformer) is a CTR ranking model introduced by Qiwei Chen, Huan Zhao, Wei Li, Pipei Huang, and Wenwu Ou (Alibaba) in their 2019 DLP-KDD workshop paper “Behavior Sequence Transformer for E-commerce Recommendation in Alibaba”. The model adds a transformer encoder layer over the user’s sequential behavior (item interaction history) on top of an otherwise-standard Wide & Deep-style ranking architecture. The transformer captures sequential signal in the user’s history that the bag-of-features baseline misses; the rest of the architecture handles the standard mix of user, item, and context features. BST was deployed in Alibaba’s Taobao production CTR ranking system, where it serves hundreds of millions of users daily and produced a +7.6% absolute lift in click-through rate over the Wide & Deep baseline at moderate inference-cost overhead (latency increased from 13ms to 20ms per inference). BST is one of the best-documented examples of transformer-style sequence modeling integrated into a ranking (rather than retrieval) stage of a multi-stage recommender pipeline, and the paper is unusually candid about production engineering trade-offs.
1. Why BST — Sequence in the Ranker
By 2019, transformer-based sequential models like SASRec and BERT4Rec had demonstrated strong performance in retrieval (next-item-given-history). Production CTR-ranking systems, however, were dominated by Wide & Deep and similar bag-of-features models that did not model the sequential structure of user behavior. The user’s recent behavior was typically encoded by averaging item embeddings from the recent history (as in the YouTube candidate generator) — losing the sequential information.
BST proposed adding a transformer encoder over the user’s behavior sequence inside the ranker, capturing the sequential signal that averaging discards. The rest of the ranker — categorical embeddings for user/item features, dense MLPs, sigmoid output — is unchanged from the Wide & Deep template. The architectural addition is targeted: just a sequence-encoding component, plugged into an existing ranker.
The lesson the paper drew was that order matters even in CTR ranking, and that adding a small transformer layer over recent behavior gives substantial production lifts at acceptable compute cost.
2. The Architecture
flowchart TD Hist[User behavior sequence<br/>i_1, i_2, ..., i_t] Target[Target item to rank] Other[Other features:<br/>user demographics, context, item metadata] Hist --> Emb[Item embedding lookup<br/>+ positional embedding] Target --> TEmb[Target item embedding] Emb --> Trans[Transformer encoder<br/>(self-attention layer)] Trans --> SeqOut[Sequence representation] SeqOut --> Concat TEmb --> Concat Other --> Concat Concat[Concatenate] --> MLP[Deep MLP<br/>(3 layers)] MLP --> Sig[Sigmoid] Sig --> CTR[Predicted CTR]
What this diagram shows. The user’s behavior sequence (a fixed-length truncation of the user’s recent item interactions) is embedded with positional encodings and passed through a transformer encoder layer. The transformer’s output — a sequence representation that captures both content and order — is concatenated with the target item embedding and other features (user demographics, context, item metadata). The combined feature vector is passed through a deep MLP with sigmoid activation to produce the predicted click-through rate. The key insight from this diagram is that the transformer layer is a targeted addition — only the sequential behavior gets transformer processing; everything else uses the standard Wide & Deep encoding. This minimizes the compute overhead while capturing the sequential signal that pure bag-of-features models miss.
3. The Transformer Encoder Detail
The transformer encoder in BST is a single layer (the paper found multiple layers gave diminishing returns and increased latency). The self-attention is bidirectional (no causal mask) because BST is a ranking model — it has access to the full history at scoring time, not just past prefix. The attention computation is the standard:
Q = X · W^Q, K = X · W^K, V = X · W^V
Attention(Q, K, V) = softmax( Q · Kᵀ / √d_k ) · V
with multi-head attention (typically 4 or 8 heads) and a position-wise feed-forward network after the attention.
The positional encoding follows the BERT-style learned positional embedding. The behavior sequence length is truncated to a maximum (typically 30–50 most-recent items in Taobao deployment).
4. Production Engineering Lessons
The BST paper is unusually informative about production engineering trade-offs at industrial scale.
Sequence length truncation matters. Including the user’s full lifetime history would be infeasible (some users have years of behavior). The paper found that the most recent 20 items captured most of the signal; longer sequences improved metrics marginally at high compute cost.
Latency overhead is acceptable. The transformer layer adds ~7ms to per-inference latency (13ms baseline → 20ms with BST). For Taobao’s production system this was acceptable; for systems with stricter latency budgets, the trade-off may be different.
Serving at scale requires careful batching. The transformer’s self-attention is O(L²) per request, making batched serving important for throughput. The paper describes the production serving infrastructure in detail.
Online improvement vs offline. The paper reports +7.6% online CTR lift versus +0.5% offline AUC lift. The disparity reflects the well-known issue that offline metrics correlate weakly with online lift, especially when the offline test set is biased by the previous recommender. BST’s online lift was substantial enough to justify deployment despite the modest offline numbers.
5. The Training Setup
Trained on Taobao’s daily logs: roughly 47.6 billion examples from 298 million users and 12.2 million items. Seven days of data for training, one day for testing. Standard CTR-prediction binary cross-entropy loss, Adam optimizer.
The scale is large enough that the model is trained on Alibaba’s distributed training infrastructure with model parallelism on the embedding tables (similar to DLRM’s setup).
6. When to Use BST
BST is appropriate when:
- You have a CTR ranking model with bag-of-features architecture (Wide & Deep, DeepFM) and want to add sequence-awareness.
- The user’s recent behavior is informative for the ranking task.
- You can afford the ~50% latency overhead of adding a transformer layer.
Do not use BST when:
- Sequence is unimportant in your domain.
- You need retrieval, not ranking — use SASRec or Two-Tower Retrieval Model for retrieval.
7. Strengths
- Production-proven at the largest e-commerce scale.
- Targeted addition — only adds sequence handling where it helps.
- Clear empirical lift in online A/B testing.
- Compatible with existing Wide & Deep / DeepFM rankers — easy to add to existing infrastructure.
8. Weaknesses
- Bounded sequence length — long histories truncated.
- Latency overhead — non-trivial for tight serving budgets.
- Single transformer layer — limited capacity compared to deeper transformer-based sequential models.
9. See Also
- SASRec — pure sequential retriever; complementary upstream model
- BERT4Rec — alternative bidirectional transformer for retrieval
- Wide & Deep — the bag-of-features baseline BST extends
- DeepFM — alternative bag-of-features ranker
- DLRM — Meta’s similar-scale ranker
- YouTube Deep Recommender — averaging-based history encoder; predecessor approach
- Sequence-Aware Recommenders — umbrella note
- Recommender Algorithms Catalog
- Recommender Systems