Designing a Credit Offer Recommendation Engine
Machine LearningModel answerLast updated
Design an end-to-end ML system that serves personalized financial product offers to millions of users, handling sparse delayed conversion signals and strict latency requirements.
Credit Offer Recommendation Engine
A consumer finance platform wants to surface relevant credit products — cards, personal loans, balance-transfer offers — to the right users at the right moment. Your task is to design the ML system that powers these recommendations end-to-end.
Context and constraints
- Traffic: 50 million daily active users, response required in under 200ms (p99).
- Catalog: Several thousand active offers from multiple issuing partners.
- Available data: User profiles, periodic credit score snapshots, historical application records, and interaction logs (impressions, clicks, dismissals, application events).
- Signal problem: Approval or funding events — the most valuable conversions — arrive days to weeks after the original recommendation, and they are rare relative to impressions.
What to cover
- Objective framing: What should the system actually optimize for, and why is raw click-through rate the wrong target?
- Candidate generation and ranking pipeline: How do you narrow thousands of offers to a ranked shortlist within the latency budget?
- Features: Which signals are most predictive of credit product propensity? How do you keep real-time and batch features consistent between training and serving?
- Delayed and sparse labels: How do you train reliably when the most meaningful conversion signal lags by weeks and positive examples are scarce?
- High-level architecture: Describe the key components — retrieval index, feature store, ranking service, logging pipeline — and how data flows through them.
- Offline and online evaluation: How do you measure model quality before and after deployment?
Cover trade-offs, realistic scale numbers, and the most common failure modes at each stage.
Hints
Hint 1
Before designing anything, think about what a single recommendation is actually worth. The answer changes the loss function you use and the features you prioritize.
Hint 2
A two-stage pipeline (cheap retrieval followed by expensive ranking) is standard, but the latency budget tells you exactly how much time each stage can spend. Work backwards from 200ms to allocate that budget.
Hint 3
Delayed conversions and sample-selection bias are two distinct problems that require different fixes. Make sure you can name both and explain why a naive approach fails for each.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify the objective before touching data
Raw CTR is the wrong thing to optimize. It rewards surfacing flashy offers regardless of whether the user qualifies, which wastes hard credit inquiries, erodes trust, and earns no partner revenue if the application is declined. A better objective is expected value per impression:
E[value] = P(click) × P(apply | click) × P(approve | apply) × partner_payout
This ties the model directly to business outcomes. It also exposes a practical tension: the approval probability term is sparse and delayed, while the click term is dense and immediate. The architecture has to serve both.
Back-of-envelope scale:
- 50M DAU × ~3 sessions × 1–2 promo surfaces ≈ 200M requests/day → ~2.3k average QPS, ~10k+ at peak.
- Latency budget split: ~20ms retrieval, ~30ms feature fetch, ~50ms ranking, remainder for business logic and network.
- Label density: CTR ~2–5%, application rate ~10% of clicks, approval data delayed days to weeks. Each funnel stage is roughly an order of magnitude sparser than the one above it.
2. Candidate generation and ranking
Stage 0 — Hard eligibility filter. Deterministic rules applied before any model: state availability, issuer minimum score requirements, products the user already holds, compliance constraints. This trims ~5k offers to ~1–2k cheaply.
Stage 1 — Retrieval (~20ms). The goal is to collect 200–500 plausible candidates. Union several sources:
- A two-tower model: user tower encodes credit profile and recent activity; offer tower encodes product attributes. Offer embeddings are precomputed nightly and served via an ANN index (FAISS or ScaNN works; with only thousands of offers, brute-force dot product is also viable). Training uses click and app-start positives with in-batch negatives.
- Rule-based segment pools: high-utilization users get balance-transfer and consolidation offers; recent inquiry bursts suggest active shopping.
- Popularity and new-offer buckets: these feed exploration and handle cold-start for new products.
Stage 2 — Ranking (~50ms over ~300 candidates). A multi-task deep model (DCN-v2 or MMoE architecture) with separate heads for P(click), P(apply | click), and P(approve | apply). Train P(click) × P(apply) jointly over the full impression space using an ESMM-style formulation — this is critical because it avoids sample-selection bias: conversion labels only exist for items that were clicked, so training a CVR model only on clicked items produces a biased estimator. ESMM trains over all impressions by decomposing pCTCVR = pCTR × pCVR.
Cross features — user score band × offer minimum score, user utilization × product type — carry significant predictive signal.
Stage 3 — Re-ranking. Combine heads into the expected-value score, then apply: a minimum approval-odds floor, diversity across issuers and product types, frequency caps, partner budget pacing, and exploration slots (epsilon-greedy or UCB).
3. Feature engineering
The most predictive features for financial product propensity:
- Credit state: current score and score delta (a recent jump signals new eligibility), utilization rate, number of open tradelines, recent hard inquiries, delinquency history, estimated debt-to-income.
- Intent signals: recent offer views, loan calculator usage, approval-odds page visits, prior dismissals of a product type in the current session.
- Offer attributes: APR range, annual fee, rewards category, historical approval rate per score band, issuer.
- User × offer crosses: score margin over issuer minimum, whether the user holds another card from the same issuer, segment-level historical CTR for this offer.
- Context: surface, device type, time of day, position in the list (used as a training-only feature to debias position effects; do not pass to the model at inference).
Batch vs. streaming freshness:
- Batch (daily, Spark → offline store + online KV): credit snapshot aggregates, 30/90-day engagement counts, offer-level approval statistics.
- Streaming (Kafka → Flink → Redis, seconds of lag): in-session clicks, dismissals from the last hour, a freshly triggered credit score refresh.
Use a feature store with point-in-time-correct joins for training, and log the exact feature vector served at inference time alongside a request_id. This eliminates training/serving skew and enables correct attribution later.
4. Delayed and sparse labels
Two separate problems require separate solutions:
Sparsity: solve with multi-task learning. The click and app-start heads are trained on dense, fast-arriving labels. The shared lower layers learn rich user and offer representations from that signal, and the approval head benefits even though it sees far fewer positives. Do not train the approval head in isolation.
Delay: three practical approaches, increasing in complexity:
-
Attribution window with a waiting period. Define conversion as approval within 30 days of impression. Only finalize a negative label after the window closes. Simple and unbiased, but the model trains on 30-day-old data — acceptable for the approval head since credit profiles drift slowly.
-
Hybrid freshness (recommended baseline). Train click/app-start heads daily on fresh data; train the approval head on matured, closed-window data. Different refresh cadences for different heads. This is the practical choice for most teams.
-
Delayed feedback modeling. Model
P(convert)jointly with a delay distributionP(delay | convert). An unconverted impression of agetcontributes likelihood(1 − p) + p · S(t), whereSis the survival function of the delay distribution (Chapelle-style DFM). Alternatively, insert immediate fake negatives and correct with importance weights when late positives arrive (FNW/FNC). More accurate, significantly more complex to implement and debug.
Start with approach 2; treat approach 3 as an upgrade once the baseline is stable.
5. Architecture
Client → API Gateway → Recommendation Service
├─ Eligibility Rules Engine
├─ Retrieval (ANN index + segment pools)
├─ Online Feature Store (Redis / DynamoDB)
├─ Ranking Model Server (Triton / TF Serving)
└─ Re-ranker (value score, diversity, pacing)
↓ impression log + served feature vector (Kafka)
Flink ──────────────────────────────────────────────────→ online store (real-time features)
Spark ── label joins, attribution, point-in-time correct → training pipeline (daily)
Partner postbacks (approval / funding) ────────────────→ label join pipeline
Model registry → shadow deploy → canary → full rollout
Fallback: if the ranker exceeds its latency SLA, serve a cached per-segment top-offer list from the feature store. Cache candidate lists per user for several minutes to reduce retrieval pressure.
6. Evaluation
Offline:
- AUC and log-loss per head.
- Calibration is especially important here: the heads are multiplied together to produce the final score, so a miscalibrated approval head distorts rankings even if its AUC looks fine. Inspect reliability diagrams and apply Platt scaling or isotonic regression if needed.
- NDCG@k and recall@k for the retrieval stage on a held-out impression set.
- Always evaluate on a time-based split, never a random split. Leakage from future credit events is easy to introduce accidentally.
Online:
- A/B test on a user-level random split. Primary metrics: application rate and approval rate (not just CTR). Guard metrics: page engagement and return visit rate.
- Watch for position bias in early experiments — the new model may rank differently and inflate CTR simply by occupying better slots.
- Monitor for feedback loops: if the system consistently shows certain offer types to a cohort, the training data for other offer types in that cohort decays. Periodic exploration slots and cohort-stratified sampling help.
Common mistakes to avoid: optimizing CTR without an approval-odds floor (rejected applicants, hard inquiries, lost trust); training CVR only on clicked items (sample-selection bias); using a random train/test split on timestamped data (future leakage); ignoring calibration on multiplied probability heads; and treating all delayed negatives as true negatives before the attribution window closes.