Next Item Recommender Using BERT4Rec
Replacing collaborative filtering with a bidirectional Transformer sequence model for a 10M-user e-commerce catalogue — and serving it under 70ms in production.
Predicting the Next Purchase, Not Just Similar Products
A large e-commerce client operating across fashion, electronics, and lifestyle wanted better accuracy and relevance from their recommendation engine. They had been running standard collaborative filtering, which hit a wall on three fronts: scalability, cold start, and an inability to read sequential patterns in user behaviour.
The objective was a next-item recommendation system that predicts the most probable next purchase. We modelled the problem sequentially and built on BERT4Rec — a Transformer-based sequential recommendation architecture that treats a user's interaction history the way BERT treats a sentence.
Four Problems Standing in the Way
Data Sparsity & Sequence Noise
Scalability
Cold Start & Long Tail
Latency Requirements
Model Training Setup
Interaction logs in, masked-item prediction out — four stages from raw event stream to a converged model in roughly 20 hours of distributed training.
Data Pipeline
Model Architecture
Training Strategy
Evaluation Protocol
Measured Against the Collaborative-Filtering Baseline
Offline evaluation ran on held-out sequences using the three standard ranking metrics — Hit Rate@K, NDCG@K, and Mean Reciprocal Rank — before anything reached live traffic.
Model Deployment Setup
A deep sequence model at sub-100ms is a systems problem before it's a modelling problem. Here's the serving path a request actually takes.
ONNX Export
Trained model exported to ONNX for optimized, framework-independent inference.
TensorRT Serving
GPU-based serving compiled through TensorRT for low-latency execution.
Kubernetes
Hosted on a K8s cluster with horizontal scaling driven by traffic load.
FEAST Feature Store
Latest user sequence pulled at inference time from the feature store.
Real-Time API
REST endpoint under 70ms per request, with a caching layer for frequent queries.
Reliability & fallback
Monitoring & retraining
What It Moved for the Business
Higher Conversion Rates
Personalized, context-aware recommendations drove a +15% uplift in conversion — strongest in multi-category sessions.
Reduced Bounce Rates
More engaging recommendations lengthened sessions and cut bounce rate by roughly 12%.
Better User Experience
Real-time accuracy plus cross-device consistency, thanks to centralized sequence tracking.
Operational Efficiency
Automated retraining and scalable serving cut operational overhead and sped up model updates.
Room to Scale
The Transformer backbone extends to multi-modal inputs (images, descriptions) and multi-task cross-sell and upsell heads.
Switching from collaborative filtering to BERT4Rec-based sequential recommendation materially advanced the client's recommendation capability — better business metrics, and a future-proof architecture aligned to their growth.
The Transformer backbone leaves room to grow: multi-modal inputs (product images and text descriptions) and multi-task heads for cross-sell and upsell are natural extensions on the same trained sequence encoder. The project underscores what advanced architectures are worth in large-scale, real-time e-commerce personalization — provided the serving path is designed with the same rigour as the model.
Have a Recommendation Problem Like This?
Bring your catalogue size, your event volume, and your current baseline metrics. In 30 minutes we'll tell you whether a sequence model is worth it — and roughly what it takes to serve one.