Designing a Ranking and Exploration Pipeline for Fresh Ad Campaigns
Machine LearningModel answerLast updated
Design an ML system that ranks and safely explores ads under one week old with little click or conversion history, while keeping auction pricing, user experience and advertiser pacing intact.
Context
You work on the ads ranking stack of a large visual discovery app. Every day, many thousands of new ad campaigns go live. During their first week these ads have almost no click or conversion history, so a standard auction ranker that orders ads by eCPM = bid * pCTR * pCVR has unreliable inputs for them. The result is one of two failure modes: new ads are starved of impressions and never get a chance to prove themselves, or weak ads are over-shown, hurting users and burning advertiser budget.
Design an end-to-end system that ranks and explores cold ads, meaning ads younger than 7 days or with fewer than about 1,000 impressions.
What the system must do
- Priors from content and context: produce initial CTR and CVR estimates for ads with zero or very little data, using creative embeddings, ad text, advertiser history, campaign metadata, and user and request context.
- Safe exploration: decide how to give promising new ads extra exposure (for example with a contextual bandit or an uncertainty-based boost) while limiting harm from negative user feedback and wasted advertiser spend.
- Calibrated predictions: output pCTR and pCVR that are well calibrated, so that exploration does not distort prices or revenue in the auction.
- Graduation to the mature ranker: define how an ad moves from the cold-start path to the main high-volume ranker as evidence accumulates.
- Delayed conversions: handle conversion labels that arrive 1 to 7 days after the click, both in model training and in any online statistics.
Scale and service constraints
- Peak load of 100,000 ranking requests per second.
- 50 million candidate ads, of which 10% to 15% are cold.
- P99 ranking latency below 40 ms.
- A newly created ad must be servable within 5 minutes; priors and bandit state must refresh in near real time.
Topics to cover
- Overall architecture: retrieval, scoring, exploration, and streaming data flow.
- Modeling: feature representation (such as two-tower or graph-based priors) and how you quantify uncertainty.
- Marketplace integrity: keeping a GSP or VCG-style auction fair while adding exploration.
- Evaluation: offline simulation and metrics, plus online experiment design, without hurting revenue or CTR.
Hints
Hint 1
Start by sizing the problem: how many cold ads exist, how many candidates are scored per request, and how the 40 ms budget splits across retrieval, ranking and auction. This tells you how cheap the per-candidate cold logic must be.
Hint 2
Separate the question of who wins from the question of what they pay. Exploration can adjust the ranking score, but pricing should rely only on calibrated eCPM values.
Hint 3
Represent each ad's CTR and CVR as a Beta posterior whose starting strength comes from the prior model's confidence, then sample from it (Thompson sampling). For conversions, count unresolved clicks as fractional trials using the delay distribution.
Hint 4
Do not graduate ads with a hard cutoff. Blend cold and mature predictions in logit space with a weight driven by how much evidence has accumulated, and log propensities so you can evaluate off-policy later.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and size
- Cold inventory: 10% to 15% of 50M ads is roughly 5M to 7.5M ads, with about 1M new ads per day.
- Compute: at 100k QPS and about 500 candidates per request, the system performs around 50M scorings per second. Any cold-specific logic must be a few arithmetic operations per candidate, such as one Beta draw, rather than a heavy model call.
- Latency split (P99 40 ms): roughly 10 ms retrieval, 20 ms ranking, 5 ms auction and pacing, remainder as slack.
- Freshness: embeddings, index insertion and priors must come from a streaming path, not a nightly batch.
- Objective: maximize long-run marketplace value by finding good new ads quickly, subject to an explicit exploration budget (for example at most 1% to 2% of revenue), bounded user harm (hides, reports) and respected advertiser pacing.
- Definition of cold: age below 7 days or below about 1,000 impressions. In practice, graduation should depend on posterior confidence, not on age alone.
2. Architecture
Ad creation path (under 5 minutes). A campaign-created event goes onto a message queue. A stream job computes image and text embeddings plus landing-page and category features, upserts the ad into the ANN index (incremental insert) and the online feature store, and a prior service writes initial Beta posteriors for CTR and CVR into a low-latency key-value store.
Serving path.
- Retrieval: the normal retrieval runs, plus a dedicated cold lane, an ANN search over content embeddings restricted to cold ads, guaranteeing around 50 cold candidates per request. Without it, cold ads never reach the ranker.
- Scoring: mature ads use the production ranker; cold ads use the cold-start model; outputs are blended (section 6).
- Exploration layer: a Thompson sample or bonus is computed for cold candidates under guardrails.
- Auction: GSP using calibrated eCPM for pricing.
Feedback path. Impressions, clicks and conversions stream into per-ad posterior counters updated within seconds to minutes. The cold model trains incrementally every hour; the mature ranker retrains daily. Every serving decision logs its propensity, which makes off-policy evaluation possible.
3. Modeling
- ID-free content model. A ranker without ad-ID embeddings, using creative and text embeddings, category, objective, bid type, advertiser aggregates, plus user and context features. Train it on all ads with ID dropout so it generalizes to unseen ads.
- Hierarchical priors. Shrink estimates along advertiser, campaign, ad group and ad, with category-level priors as the fallback for brand-new advertisers. An advertiser similarity graph (shared categories, landing domains, audience overlap) can transfer priors to new accounts.
- Warm ID embeddings. A small meta-network maps content features to an initial ID embedding so the mature ranker can absorb the ad faster than from a random start.
- Uncertainty. Model CTR as a Beta posterior: alpha0 = p_prior * n0 and beta0 = (1 - p_prior) * n0, where the prior strength n0 comes from model uncertainty (ensemble or MC-dropout variance, mapped through a fitted calibration). Confident priors get large n0; unusual ads get small n0 and therefore explore more. After observing data the posterior is Beta(alpha0 + clicks, beta0 + impressions - clicks). CVR uses the same structure with delay correction.
- Exploration policy. Thompson sampling on the per-ad posterior, used as a multiplier on the contextual pCTR. It is cheap (one draw per candidate), stochastic (so propensities are clean) and needs only two numbers per ad. LinUCB is an option but needs matrix state per arm, which is costly at millions of arms.
4. Marketplace integrity and calibration
The key principle: exploration changes who wins, never what anyone pays.
- Ranking score = bid * pCTR_cal * pCVR_cal + bonus, where the bonus is the sampled value minus the posterior mean, scaled.
- Pricing uses calibrated eCPM only. A boosted winner pays as if there were no bonus: the runner-up's calibrated eCPM divided by the winner's calibrated pCTR * pCVR, capped at the bid.
- The gap between boosted rank and true value is a platform subsidy, tracked as exploration cost against a global budget enforced by a controller (for example a PID loop on hourly exploration spend).
- Calibration: isotonic or Platt calibration per segment, including ad-age buckets, since cold predictions tend to be overconfident at the extremes. Monitor ECE and predicted-to-observed ratio per bucket.
- Guardrails: cap exploration at about 2% of impressions, cap per-ad and per-advertiser exploration, exclude ads with a high predicted hide or report probability, and never let exploration push spend beyond the advertiser's pacing plan.
5. Delayed feedback
CTR labels arrive in minutes; CVR labels arrive over 1 to 7 days.
- Training: treating recent clicks as negatives biases CVR downward, most for the newest ads. Options: a delayed-feedback model that factors P(convert) and P(delay <= elapsed); importance-weighted fake-negative correction with later label updates; or separate fast CTR and slower CVR heads, the latter trained on matured windows plus correction.
- Bandit state: treat an unresolved click as a partial trial. Effective CVR trials = sum of F(t_i), with F the delay CDF and t_i the time since click i. The posterior is Beta(alpha0 + conversions, beta0 + sum F(t_i) - conversions), which keeps variance honest instead of shrinking it too early.
6. Graduation
Avoid a hard switch at a fixed impression count. Blend in logit space:
logit(p) = w * logit(p_mature) + (1 - w) * logit(p_cold)
Let w rise smoothly with evidence, for instance w = n / (n + k) or a function of posterior variance, so uncertain ads lean on the cold model and well-observed ads lean on the mature one. Once w is near 1 and posterior variance is small, remove the ad from the cold lane and exploration pool. Verify there is no score discontinuity at the boundary.
7. Evaluation
- Offline: replay logged data with inverse propensity weighting or doubly robust estimators (this is why propensities are logged). Build a simulator seeded from historical campaigns to test policies on regret, time-to-discover top ads and budget burn. Report AUC and log loss, but prioritize calibration by age bucket.
- Online: randomize at the advertiser or campaign level where possible to limit interference between ads competing in the same auction; otherwise use budget-split or two-sided experiments. Primary metrics: revenue and advertiser value for new ads, 7-day survival of new advertisers, CTR. Guardrails: hide and report rates, calibration ratio, pacing error, and latency (P99 < 40 ms).
- Long-term: use holdouts, since benefits (advertiser retention, better ad discovery) show up over weeks.
Common mistakes
- Putting the exploration bonus into the price, which breaks auction incentives.
- Having no dedicated cold retrieval lane, so cold ads are never scored.
- Hard graduation thresholds that cause score jumps.
- Ignoring delayed conversions, so new ads look worse than they are.
- Skipping propensity logging, which makes later evaluation impossible.
- Using per-arm matrix bandits at millions of arms.