Common ML Models for System Design
ML system design interviews aren't modeling exams. Nobody expects you to derive backpropagation or tune a learning rate on the whiteboard. But at some point every applied ML round reaches the question "so what model would you use?", and the answer tells your interviewer a lot. Saying "a transformer" for a fraud model with 200 tabular features is a red flag. Saying "logistic regression" for a feed ranker with a billion users and no plan to grow from there is another.
What interviewers want is a justified choice: a simple baseline you'd ship first, the model you'd move to as data and requirements grow, and the trade-offs that drive the move, like data volume, latency budget, the kind of inputs, and how much you need to explain a decision. That needs a working knowledge of maybe eight model families, not eighty.
We'll go through them in roughly the order you'd reach for them:
- Linear models: logistic regression and factorization machines.
- Gradient-boosted decision trees.
- Embeddings, the building block of everything deep.
- Two-tower models for retrieval.
- Deep ranking models: Wide & Deep, DeepFM, DCN and DLRM.
- Sequence models, from RNNs to attention over user history.
- Transformers and LLMs.
- A few specialists: CNNs and detectors, graph models, anomaly detection, bandits.
Then a comparison table, and a practical guide to choosing in an interview.
Logistic Regression
Logistic regression predicts a probability as the sigmoid of a weighted sum of features:
P(y = 1 | x) = σ(w · x + b) = 1 / (1 + e^-(w · x + b))
It's trained by minimizing log loss (binary cross-entropy), usually with L2 regularization to prevent overfitting or L1 to push most weights to zero.
What makes it still relevant:
- Calibrated by construction. Trained with log loss, its outputs are good probability estimates on data like the training data. That matters when the probability itself is used, like an expected-value calculation in an ad auction or a fraud threshold set in dollars.
- Extremely fast. Scoring is a sparse dot product: microseconds, on a CPU, even with millions of features.
- Interpretable. Each weight says how much a feature moves the log-odds. You can explain any single decision.
- Scales to huge sparse inputs. With the hashing trick, any categorical value (
country=BR,ad_id=81723,country=BR × ad_category=games) is hashed into a fixed-size weight vector of, say, 2^24 entries, without building a vocabulary. - Online learning. Algorithms such as FTRL-Proximal update the weights one example at a time and produce sparse models, which made logistic regression the classic workhorse of click-through-rate prediction for years.
Its limit is that it's linear in its features. It can't learn on its own that "young users like this category, but only on mobile." Every interaction has to be a hand-made feature cross, and the number of useful crosses explodes.
Factorization machines (FM) fix part of this. They add a learned vector for every feature and model every pairwise interaction as the dot product of two vectors:
ŷ = w0 + Σ w_i x_i + Σ_{i<j} (v_i · v_j) x_i x_j
A pair that never appeared together in training still gets a sensible interaction weight, because each feature's vector is learned from all the pairs it does appear in. FMs are the bridge between linear models and the embedding-based deep models later in this post; DeepFM literally has an FM inside it.
Logistic regression is almost always the right "baseline" to name first for a binary prediction problem. Say what you'd feed it (a few hundred features, with hashed crosses), why it's useful (fast, calibrated, debuggable, sets a bar), and what you'd expect to gain by moving on. Interviewers like candidates who can measure whether the fancy model is worth it.
Gradient-Boosted Decision Trees
A gradient-boosted decision tree (GBDT) model is a sum of many small decision trees, trained one after another. Each new tree is fit to the gradient of the loss with respect to the current predictions; for squared error, that's simply the residuals the previous trees got wrong. After a few hundred trees of depth 6 to 8, the ensemble captures complex non-linear patterns and interactions.
The three libraries you'll name are XGBoost, LightGBM (fast histogram-based training, leaf-wise growth) and CatBoost (good native handling of categorical features).
Why GBDTs are the default for tabular data:
- No feature preprocessing. Splits only care about order, so features don't need scaling, and outliers don't distort the model. Missing values are handled natively.
- Interactions for free. A path down a tree is a conjunction of conditions ("amount > $500 and account age < 2 days and country mismatch"), which is exactly the kind of rule fraud and risk models need.
- Strong with moderate data. Tens of thousands to tens of millions of rows with tens to a few thousand features is the sweet spot. On this kind of data, well-tuned GBDTs often match or beat deep networks.
- Fast enough to serve. Scoring is one root-to-leaf walk per tree. 500 trees × depth 8 is about 4,000 comparisons, which takes on the order of tens of microseconds per example on a CPU. Scoring 1,000 candidates is a millisecond or two.
- Explainable. Feature importance shows what the model relies on globally, and SHAP values attribute each individual prediction to features. Regulated decisions (credit, fraud, insurance) often need exactly this.
Where they struggle:
- High-cardinality IDs. A GBDT can't do much with a raw
user_idamong 500 million values. You have to turn IDs into dense features first: historical CTR for this ID, counts, or an embedding similarity computed elsewhere. - Unstructured inputs. Text, images, audio and long behavior sequences need another model to turn them into features.
- Incremental learning. GBDTs are usually retrained from scratch on a window of data. Continuous online updates are awkward.
- Calibration. Outputs are often slightly miscalibrated and get a post-hoc fix (Platt scaling or isotonic regression) when probabilities matter.
GBDTs also do learning to rank: LambdaMART is a GBDT trained with a ranking-aware objective and was a standard for web search ranking.
Typical interview uses: fraud and risk scoring, ETA prediction, dynamic pricing, churn, lead scoring, the first ranker of a recommender, and a strong second stage behind a neural model. See ML Fraud Detection and ETA Prediction.
Embeddings
An embedding is a learned dense vector that represents a discrete thing (a user, an item, a word, a merchant) or a piece of content (a sentence, an image) such that similar things have nearby vectors.
There are two ways to get them:
- Learned as part of a model. An embedding table is a lookup: row
iholds the vector for IDi, and those rows are trained by backpropagation along with the rest of the network, so the vectors end up encoding whatever helps predict the label. This is how deep recommenders handle IDs. - Pretrained encoders. A separate model maps content to vectors: text encoders (BERT-family models, sentence-transformers, embedding APIs), image encoders (CNNs, vision transformers), and joint image-text models like CLIP. You can use them as-is, or fine-tune on your task. Older but still useful: word2vec-style skip-gram models trained on sequences, which applied to sessions of item IDs give "item2vec" embeddings where items that appear in similar contexts end up close.
Once you have embeddings, you can use them as features in any model (including a GBDT, via similarity scores), for retrieval with nearest neighbor search, for clustering and deduplication, and for cold start, since content embeddings exist before any interaction does.
Size them before you propose them. Embedding tables are where deep recommenders spend their memory:
500M users × 64 dims × 4 bytes = 128 GB
1B items × 64 dims × 4 bytes = 256 GB
That's bigger than one GPU, so large systems shard embedding tables across GPUs or parameter servers, use hashing to map IDs into fewer rows (accepting some collisions), drop or share rows for rare IDs, and store tables in reduced precision (fp16 or int8). Mentioning this unprompted is a clear senior signal.
Two-Tower Models
The two-tower model is the standard for retrieval: one network encodes the user or query, another encodes the item, and the score is their dot product. Because the towers only meet at the dot product, item vectors can be precomputed and indexed, and finding the best of 100 million items becomes an approximate nearest neighbor search that takes a few milliseconds.
The same shape shows up outside recommendation: query and document towers for semantic search, question and passage encoders for RAG, and image and text towers in CLIP. In every case the strength (independent encoders, precomputable item side) is also the limit: the model can't model fine-grained interactions between the two sides, so it's followed by a ranker or a cross-encoder that reads both together.
Training details (in-batch negatives, logQ correction, hard negatives) and serving with HNSW or IVF-PQ are covered in Recommendation System Fundamentals and Vector Databases.
Deep Ranking Models
When a ranking problem has billions of training examples and lots of sparse categorical features, deep models with embeddings beat GBDTs. A few architectures cover most of what you'll discuss.
Wide & Deep
Wide & Deep trains two parts jointly and adds their outputs before the sigmoid:
- The wide part is a linear model over raw features and hand-picked crosses. It's good at memorization: "users who installed app A install app B."
- The deep part embeds every sparse feature, concatenates the embeddings with dense features, and runs an MLP. It's good at generalization: it can score combinations it has never seen, because similar apps have similar embeddings.
It's a clean way to explain the memorization vs generalization trade-off, and a natural step up from logistic regression, since the wide side is the old logistic regression model.
DeepFM and DCN
The weakness of Wide & Deep is that someone still hand-picks the crosses for the wide side. Two popular successors learn them:
- DeepFM replaces the wide part with a factorization machine, so all pairwise interactions are learned from feature embeddings. It shares the embeddings between the FM and the deep part.
- DCN (Deep & Cross Network, and its improved DCN-v2) adds a cross network: layers that explicitly multiply the input by itself, so each layer adds one more degree of feature interaction cheaply.
DLRM
DLRM is a clean, widely used reference architecture for click prediction:
- Dense features (counts, rates, ages) go through a bottom MLP into a vector the same size as the embeddings.
- Each sparse feature (user ID, item ID, category, device) is looked up in its own embedding table.
- An interaction layer takes the dot product of every pair of these vectors, which is the FM idea again.
- The pairwise interactions and the dense vector are concatenated and go through a top MLP to a sigmoid.
The interesting part for system design is the shape of the cost: embedding tables are huge but each lookup is cheap, while MLPs are small but compute-heavy. So training uses model parallelism for embeddings (tables sharded across GPUs, with all-to-all communication to exchange looked-up vectors) and data parallelism for the MLPs. Libraries such as TorchRec exist mainly to do this sharding.
Multi-Task Heads
Real rankers predict several actions: click, like, share, purchase, hide. Training one model per action duplicates the features and wastes the shared signal. A shared-bottom network with one tower per task is the simple version; MMoE (multi-gate mixture of experts) gives each task its own learned mix of shared expert networks, which reduces the harm when tasks conflict. The predictions are combined downstream with business weights. See Design an Ads Ranking System and Design TikTok's Video Recommendation System.
Serving cost. A deep ranker with a few million MLP weights, scoring 500 to 1,000 candidates per request, runs in single-digit to tens of milliseconds on CPU or GPU with batching. The user-side computation is done once per request and reused for every candidate. Embedding lookups usually hit an in-memory store sharded across machines.
Sequence Models
Many problems are about order: the last 50 things a user watched, the sequence of events in a login session, sensor readings over time, words in a sentence. A bag of features ("watched 12 cooking videos this week") loses the order and the recency. Sequence models use it.
RNNs, LSTMs and GRUs
Recurrent networks read a sequence one step at a time, updating a hidden state. LSTMs and GRUs add gates that let them remember over longer spans. They were the standard for sequences before transformers, and still appear in session-based recommendation (GRU4Rec is the well-known example), clickstream fraud features and on-device models. Their drawbacks: they process steps sequentially, which is slow to train on long sequences, and they struggle to use information from far back.
Attention Over User History
For ranking, the most influential idea is target attention: when scoring a candidate item, attend over the user's history using the candidate as the query. Past items similar to the candidate get high weight, so the same user gets a different summary of their history for each candidate. This is the core idea of Deep Interest Network (DIN), and it explains why "this user watches all kinds of videos, but the cooking ones they finish" can be captured at all.
The bigger version runs a transformer over the behavior sequence (models like BST and SASRec), which also learns how history items relate to each other. Cost grows with sequence length and candidate count, so production systems cap the sequence (a few hundred recent events), compute the history encoding once per request, and sometimes precompute long-term interest embeddings offline while attending over only the recent sequence online.
Time-Series Forecasting
Forecasting (demand per region per 15 minutes, traffic, inventory) is another sequence problem. Name the progression: a seasonal baseline (same time last week) or a classical method like exponential smoothing; then a GBDT with lag and calendar features (demand 1 hour ago, same hour last week, holiday flags, weather), which is often the strongest practical choice; then deep forecasters (LSTMs, temporal convolution, transformer-based forecasters) when there are many related series and lots of history. See Dynamic Pricing for Ride-Sharing.
Transformers and LLMs
The transformer replaced recurrence with self-attention: every position attends to every other, in parallel. That made it possible to train very large models on very large data, and it's now the default architecture for text, increasingly for images, audio and behavior sequences.
Three shapes matter in system design:
- Encoder-only (BERT and its descendants): read the whole input and produce contextual representations. Use them for classification (toxicity, intent, spam), named-entity extraction, and as embedding models for search and RAG. A base-size encoder has on the order of 100 million parameters and classifies a short text in a few milliseconds on a GPU.
- Decoder-only LLMs (GPT, Claude, Llama-style models): generate text token by token. Use them for generation, reasoning over context, extraction with flexible schemas, agents, and as zero-shot or few-shot classifiers. They're the most capable and by far the most expensive: billions of parameters, hundreds of milliseconds to seconds per request, and GPU serving. See Design an LLM Inference System.
- Cross-encoders: a transformer that reads the query and a candidate together and outputs a relevance score. Much more accurate than a two-tower model for ranking a short list, much too slow to run over a whole corpus. The standard second stage in search and RAG.
Transformers also run inside other systems: vision transformers and CNNs for images, multimodal encoders for product listings that combine image and title, and transformer rankers over user sequences.
How to use them well in a design:
- Prompt a hosted LLM when data is scarce, the task is new, volume is low or quality matters more than cost: a few thousand moderation appeals a day, extracting fields from unusual invoices.
- Fine-tune a smaller model (an encoder, or a small LLM with LoRA) when volume is high, the task is stable and you have labels. A fine-tuned 100M-parameter classifier is often as accurate as a large prompted LLM on a narrow task, at a tiny fraction of the cost and latency.
- Distill: use the big LLM to label data, then train a small fast model on those labels for the online path, and keep the LLM for the hard or ambiguous cases. This pattern shows up in content moderation, query understanding and search relevance.
See Design an LLM Fine-Tuning System for the training side and Inference Optimization for making large models cheaper to serve.
Don't propose an LLM in the online path of a high-QPS ranking or fraud system without doing the arithmetic. A feed ranker that scores 1,000 candidates for 100,000 requests per second is 100 million scores per second; an LLM call per score is impossible. LLMs belong where they're used offline (generating labels, item descriptions, embeddings) or at the low-QPS, high-value end (explanations, appeals, agents).
Specialists Worth Knowing
A few more families come up often enough that you should be able to name them and say when they fit:
- CNNs and object detectors. ResNet and EfficientNet-style CNNs for image classification and embeddings; detectors like YOLO or DETR for finding and boxing objects in images and video. Small variants (MobileNet-style, quantized) run on phones and cameras. See Real-Time Video Understanding and Prohibited Item Detection.
- Graph neural networks. GraphSAGE-style models learn node embeddings by aggregating features from neighbors, useful when relationships matter as much as attributes: friend suggestions, fraud rings sharing devices and cards, product co-purchase graphs. See People You May Know.
- Anomaly detection. When labels are scarce or attacks are new: isolation forests (anomalies are easy to isolate with random splits), autoencoders (high reconstruction error means unusual), and simple statistical baselines (z-scores on per-entity rates). Usually a feature or a first filter alongside a supervised model, not a replacement for one.
- Multi-armed and contextual bandits. For choosing among options with online feedback when exploration matters: which notification template, which thumbnail, which exploration candidate. Thompson sampling and LinUCB are the names to know.
- Survival and uplift models. Survival models predict when something happens (churn, time to next purchase); uplift models predict the change in behavior caused by an intervention (who a coupon actually persuades), which is what marketing and incentive problems really need.
Comparison
| Model family | Typical use | Data needs | Serving latency | Interpretability |
|---|---|---|---|---|
| Logistic regression | Baseline classifier, CTR with sparse crosses, calibrated scores | Low to very high; needs engineered features | Microseconds, CPU | High: one weight per feature |
| Factorization machines | Sparse CTR prediction with pairwise interactions | Medium to high, sparse | Microseconds, CPU | Medium |
| GBDT (XGBoost, LightGBM) | Tabular problems: fraud, ETA, pricing, churn, first ranker, LambdaMART search ranking | 10^4 to 10^8 rows, dense features | Tens of µs per example, CPU | Medium-high: feature importance, SHAP |
| Embeddings (learned or pretrained) | Representing IDs and content; similarity, clustering, cold start | Interaction logs or pretrained encoders | Lookup: sub-ms; encoder: ms | Low; inspect by nearest neighbors |
| Two-tower | Retrieval over millions to billions of items, semantic search | Millions+ of positive pairs | ~1-10 ms (user tower + ANN) | Low |
| Wide & Deep / DeepFM / DCN / DLRM | Large-scale ranking and CTR with many sparse features | 10^8 to 10^11 examples | Single-digit to tens of ms per request for hundreds of candidates | Low |
| Sequence models (RNN, DIN, transformer over history) | Session recommendation, next-item prediction, behavior-based fraud, forecasting | Long event histories at scale | ms to tens of ms; grows with sequence length | Low; attention weights give hints |
| Transformer encoders / cross-encoders | Text classification, NER, embeddings, search reranking | Pretrained; thousands+ labels to fine-tune | ms to tens of ms on GPU | Low |
| LLMs | Generation, extraction, agents, zero-shot classification, offline labeling | None to little task data (prompting); more for fine-tuning | Hundreds of ms to seconds, GPU | Low; can explain in text, not reliably |
| CNNs / detectors | Image classification, object detection, video frames | Thousands to millions of labeled images; pretrained backbones | ms per image on GPU; edge variants | Low; saliency maps |
| GNNs | Graph-shaped problems: friend suggestions, fraud rings | Graph with node and edge features | Usually offline embeddings, served by lookup | Low |
| Anomaly detection | Unlabeled or novel attacks, monitoring | Unlabeled data | Microseconds to ms | Medium |
Choosing a Model in an Interview
Start From the Inputs and the Constraints
Four questions narrow the choice quickly:
- What do the inputs look like? Tabular features with moderate cardinality point to a GBDT. Huge sparse IDs and crosses point to embeddings and a deep ranker. Text, images or audio point to a pretrained encoder (and maybe a classifier on top). Long ordered histories point to a sequence model.
- How much labeled data is there? Thousands of labels: a GBDT, or a pretrained model fine-tuned lightly, or a prompted LLM. Millions to billions: deep models start to pay off.
- What's the latency budget and QPS? Sub-millisecond per item at high QPS rules out anything big per candidate. Count the candidates: score per item × candidates per request × requests per second is your compute bill.
- Does a decision need explaining? Credit decisions, fraud declines and anything regulated favor GBDTs with SHAP, or linear models, even at some loss of accuracy.
Then Present a Progression
The strongest pattern in an interview is to name a baseline, a production model and an advanced model, and say what triggers each move:
- Fraud or risk scoring: rules and logistic regression → GBDT on rich aggregates (the production answer) → add sequence features or a GNN for rings, and an anomaly detector for new attacks.
- Feed, ads or product ranking: popularity or logistic regression → GBDT → multi-task deep ranker (DLRM/DCN family) with attention over user history, behind a two-tower retrieval stage.
- Search relevance: BM25 → learning-to-rank GBDT → two-tower retrieval plus a cross-encoder reranker.
- Text moderation or intent: keyword rules → fine-tuned encoder classifier → LLM for hard cases and appeals, distilled back into the classifier.
- ETA, pricing, demand: historical averages → GBDT with real-time features → deep models when spatial and sequential structure matters.
Common Follow-ups
- "Why not a deep model here?" Not enough data, tabular features where GBDTs are as good, a latency or explainability requirement, or the team would pay a big complexity cost for little lift. Offer to test it against the baseline.
- "Why not a GBDT?" Raw IDs and sequences matter, there are billions of examples, or you need multi-task heads and shared embeddings that tree ensembles can't provide.
- "How do you serve a model this big?" Shard embeddings, precompute the user side once per request, batch candidates, quantize, cache, distill.
- "Are the probabilities calibrated?" Check with a reliability plot or expected calibration error; fix with Platt scaling or isotonic regression; correct for negative downsampling.
- "Can you explain why a user was declined?" SHAP values on the GBDT, reason codes derived from top contributing features, and a policy layer of explicit rules on top.
Interviewers rarely care which of DCN-v2 or DeepFM you pick. They care that you know why a deep ranker beats a GBDT at that scale, what it costs to train and serve, and that you'd still ship the simpler model first to have something to measure against.
Summary
A small set of model families covers almost every ML system design question. Logistic regression is the fast, calibrated, interpretable baseline. GBDTs are the default for tabular data, strong with moderate data and easy to explain, but weak on raw IDs and unstructured inputs. Embeddings turn IDs and content into vectors and are the foundation of every deep recommender; size their tables before proposing them. Two-tower models make retrieval over huge catalogs possible by keeping the two sides independent. Wide & Deep, DeepFM, DCN and DLRM combine embeddings with learned feature interactions for large-scale ranking, usually with multi-task heads. Sequence models, especially attention over user history, capture order and recency. Transformers dominate text and increasingly everything else, as encoders for classification and embeddings, cross-encoders for reranking, and LLMs for generation and low-volume, high-value tasks.
Choose by the shape of the inputs, the amount of labeled data, the latency and QPS budget, and the need for explanations. Then present a progression from a simple baseline to the production model, and say what would make you move to the next step.