AI AutomationE-Commerce / Retail Technology

Affinity Engine — Two-Tower Neural Recommender System

Domain / Scope
E-Commerce ML / Neural Recommender
Year
2026
Duration
20 weeks
Primary metric
41% CTR lift at 22ms p95
41%
Relative CTR lift on homepage recommendation module (1.8% → 2.54%)
23%
Increase in average order value from cross-sell and upsell suggestions
22ms
P95 end-to-end inference latency (user query → ranked top-20 products)
78%
Cold-start user coverage — new users receive personalized recs within first session
14h
Full model retraining time on 840M events on distributed GPU cluster
99.95%
Inference API availability across peak seasonal traffic spikes

The Problem

System Bottlenecks & Technical Friction

E-commerce catalogs with hundreds of thousands of SKUs require recommendation architectures that go beyond simple collaborative filtering or keyword matching. Matrix factorization models frequently generate stale suggestions and struggle with cold-start users and seasonal catalog shifts. E-commerce platforms need deep dual-tower neural retrieval that encodes user behavioral history and product semantics into low-dimensional vector spaces, serving sub-30ms recommendations at scale.

Our Engineering Approach

Architecture Design & Implementation

Affinity Engine is a two-tower neural retrieval architecture. The User Tower encodes session clickstream, purchase recency, and category preferences via a Transformer encoder. The Item Tower encodes product metadata, taxonomy hierarchy, and visual features into a shared 512-dimensional embedding space. At inference time, Pinecone executes sub-15ms approximate nearest neighbor (ANN) retrieval over precomputed item vectors, followed by a lightweight XGBoost model that re-ranks candidates for click and conversion probability.

Technical Architecture

System breakdown & stack.

8 core subsystem modules
01

Two-tower Transformer architecture: 6-layer user encoder + 6-layer item encoder, 340M parameters total

02

Trained on 840M user interaction events (clicks, add-to-cart, purchases) via batch-softmax contrastive loss

03

Ray distributed training on AWS SageMaker: 32-node GPU cluster, mixed-precision FP16, gradient checkpointing

04

Pinecone vector DB with 880K precomputed item embeddings, <15ms k-NN retrieval (k=200)

05

XGBoost reranking model for CTR/CVR prediction on top-200 candidates retrieved from Pinecone

06

Feast feature store: versioned user/item features, point-in-time correctness for backfill training

07

Redis embedding cache with 10-minute TTL for repeat user queries, 92% hit rate

08

FastAPI inference API with <25ms P95 latency for end-to-end user query → ranked recommendations

PyTorchRayFeastPineconeFastAPIRedisPostgreSQLAWS SageMakerAirflowReact

Engagement Timeline

Engineering delivery schedule.

Total: 20 weeks
Weeks 1–3

User interaction data extraction, EDA, train/val/test splits, feature engineering research

Weeks 4–8

Two-tower architecture design, PyTorch implementation, initial single-GPU training experiments

Weeks 9–12

Ray distributed training setup on SageMaker, mixed-precision FP16, hyperparameter tuning

Weeks 13–15

Pinecone vector DB deployment, item embedding precomputation, k-NN retrieval optimization

Weeks 16–18

XGBoost reranking model, Feast feature store integration, FastAPI inference API build

Weeks 19–20

A/B test on 10% traffic, latency profiling, gradual rollout to 100%, monitoring dashboards

More Case Studies

Related AI projects

Want results like these for your business?

Book a 30-minute scoping call with a senior engineer. We'll scope your AI project, define the architecture, and give you a fixed-price proposal within 5 business days.