Build a Click Prediction System for Job Recommendations
Machine LearningModel answerLast updated
Design an ML system that predicts job click probability using member profiles, job attributes, and behavior logs to power ranking at serving time.
You're building a machine learning system for a career platform that shows job listings to users. Your task is to design a system that predicts the probability a user will click on a job posting when it's shown to them. This predicted probability will be used to rank which jobs appear higher in their feed.
You should define the complete system, covering:
- Data requirements: What historical data and features you need, including user behavior logs
- Training labels: How you define positive and negative examples from logged interactions
- Architecture: The offline training pipeline and online serving components
- Model training: Loss function choice, handling class imbalance, and preventing data leakage
- Feature engineering: How you represent users and jobs, including generating embeddings for both
- Cold start: How you handle new users and new job postings with little or no history
Assume you have access to user profile data, job posting metadata, and logs of which jobs were displayed and which were clicked. Treat this as a 20-minute discussion—focus on the critical decisions and trade-offs rather than every implementation detail.
Follow-up considerations:
- How do you account for position bias (jobs shown higher get more clicks regardless of relevance)?
- Should clicks be your true objective, or are you optimizing for a proxy metric?
- How do you validate the model offline and measure impact online?
Hints
Hint 1
Think carefully about what makes an impression a negative example—not every job a user didn't click should count against relevance.
Hint 2
Position bias is real: jobs at the top get clicked more often. Consider how to debias your training data or model this explicitly.
Hint 3
Cold-start users and jobs need a fallback strategy—popularity-based ranking or content-based features can bootstrap until you have interaction history.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
1. Problem Framing and Supervision Signal
The core task is binary classification: given a (user, job, context) tuple, predict P(click | impression).
Positive examples: Impressions where the user clicked the job.
Negative examples: Jobs that were shown but not clicked. However, not all non-clicks are equally informative:
- If 20 jobs were displayed and the user clicked one, the other 19 are weak negatives—the user may have been interested but satisfied their need after one click.
- Better approach: sample negatives, or weight them inversely by position and dwell time on the page.
Handling position bias: Jobs shown at position 1 naturally get more clicks than position 10, even if equally relevant. Options:
- Include position as a feature and let the model learn it (simple but may underrank good jobs trained from lower positions).
- Train a separate position bias model and divide it out.
- Use inverse propensity weighting: weight each training example by 1/P(click | position), estimated from historical CTR by position.
2. Data and Features
User features:
- Profile: seniority level, skills, location, industry, years of experience
- Behavioral: past job clicks, applications, searches; engagement recency
- User embedding: a dense vector summarizing career interests (see §5)
Job features:
- Metadata: title, company, location, salary range, seniority, required skills
- Popularity: total impressions, CTR, application rate (time-decayed to favor fresh signals)
- Job embedding: vector representing job content and context
Interaction features:
- Skill overlap: Jaccard or cosine similarity between user skills and job requirements
- Location match: same city, commutable, remote
- Salary fit: does the range overlap with user's expected salary (if available)?
Contextual features:
- Time of day, day of week, device type
- Which surface the job is shown on (feed, search results, email digest)
3. Model Architecture
Two-tower model for scalability:
- One tower encodes the user (profile + history) into a user embedding.
- Another tower encodes the job (metadata + content) into a job embedding.
- Interaction features (skill overlap, geo match) are concatenated.
- A shallow MLP combines all embeddings and outputs a click probability.
Why two-tower? At serving time, job embeddings can be precomputed and indexed (e.g., in a vector database). User embedding is computed once per request, then a dot product or lightweight scoring layer ranks thousands of candidates in milliseconds.
Loss function: Binary cross-entropy, weighted by inverse propensity to debias position effects. If severe class imbalance (CTR ~2%), consider:
- Downsampling negatives and correcting predicted probabilities:
p_corrected = p / (p + (1 - p)/w)wherewis the negative sampling rate. - Focal loss to emphasize hard examples.
4. Preventing Data Leakage
Temporal split: Train on impressions before time T, validate on T to T+7 days, test on T+7 to T+14. Never train on future data.
Leakage risks:
- Target leakage: Don't include post-click features (e.g., "user applied to this job") as inputs.
- Popularity leakage: Job CTR and application rate should be computed on data before each training example's timestamp. Use a trailing 30-day window, recomputed daily.
- User-item leakage: If the same (user, job) pair appears in both train and test (e.g., the job was re-shown), it inflates metrics. Deduplicate or filter.
Feature store: Precompute time-windowed aggregates (user's 30-day click rate, job's 7-day CTR) with point-in-time correctness to avoid leakage.
5. User and Job Embeddings
Job embeddings:
- Pretrain on job text (title + description) using a transformer (e.g., fine-tuned BERT on job postings).
- Alternatively, train embeddings end-to-end within the two-tower model using historical clicks as supervision.
User embeddings:
- Aggregate the embeddings of jobs the user recently clicked or applied to (e.g., mean pooling over last 10 interactions).
- Add profile features (skills, seniority) via a learned embedding layer.
- For cold-start users with no history, fall back to profile-only embeddings or a separate content-based model.
Cold-start jobs: New postings have no interaction history. Options:
- Use content features (job embedding, company popularity, salary percentile) until clicks accumulate.
- Exploration: reserve 5–10% of impressions for random or diverse jobs to gather data.
- Hybrid: blend content-based score with collaborative filtering as data grows.
6. System Components
Offline (training pipeline):
- Join impression logs with user profiles and job metadata.
- Compute time-windowed features (CTRs, engagement rates) with point-in-time correctness.
- Apply position-bias correction and negative sampling.
- Train the two-tower model; validate on held-out time slice.
- Export user-tower and job-tower separately; precompute and index all job embeddings.
Online (serving):
- Candidate generation: retrieve ~1,000 jobs via multiple strategies (user skills → job requirements, user embedding → similar job embeddings, trending jobs).
- Feature lookup: fetch user profile, recent interactions, and precomputed job features from a feature store.
- Scoring: compute user embedding, retrieve job embeddings, run lightweight MLP to score all candidates (~10ms).
- Ranking: sort by predicted CTR (or a blend:
score = α·P(click) + β·P(apply | click)). - Logging: record which jobs were shown, their positions, and which were clicked for the next training batch.
Retraining cadence: Daily or weekly, depending on data volume and drift.
7. Evaluation and Guardrails
Offline metrics:
- AUC-ROC and log-loss on the held-out test set.
- Calibration: plot predicted vs. observed CTR in deciles.
- Ranking metrics: MRR (mean reciprocal rank of the first click), NDCG if you have graded relevance.
Online A/B test:
- Primary: CTR (clicks / impressions).
- Secondary: application rate, time to first application, user retention.
- Guardrails: watch for filter-bubble effects (does the model stop showing diverse jobs?) and fairness (any demographic groups seeing lower-quality jobs?).
Common mistakes:
- Treating all non-clicks as strong negatives → model learns position bias instead of relevance.
- Ignoring cold start → new jobs and users get poor rankings, hurting growth.
- Training on all-time data without temporal splits → leakage inflates offline metrics, model fails in production.
- Optimizing clicks alone → users click but don't apply; consider a multi-objective or cascade model (CTR → apply rate).
8. Extensions
- Multi-objective: Predict both P(click) and P(apply | impression); rank by a weighted combination.
- Contextual bandits: Explore jobs with uncertain scores to reduce bias toward historically popular postings.
- Transformer encoder: Replace the two-tower MLP with cross-attention between user history and job content (higher quality, slower serving).