Walk me through train/validation/test splits. When do you use cross-validation, and when is it a bad idea?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Three sets, three jobs: train fits parameters, validation drives all the choices you make between runs (hyperparameters, architecture, checkpoint selection, early stopping), and test estimates generalization once, at the end. Every decision you make while looking at a set "spends" it - tune against the test set enough times and it silently becomes a second validation set, and your reported number is optimistic.
Full worked answer with diagram
Three sets, three jobs: train fits parameters, validation drives all the choices you make between runs (hyperparameters, architecture, checkpoint selection, early stopping), and test estimates generalization once, at the end. Every decision you make while looking at a set "spends" it - tune against the test set enough times and it silently becomes a second validation set, and your reported number is optimistic.
k-fold cross-validation (typically k=5 or 10) rotates the validation fold and averages, giving a lower-variance estimate when data is scarce - standard for classical ML on thousands of rows. Use stratified k-fold for imbalanced classes so each fold preserves prevalence.
When CV is wrong or impractical:
- Deep learning at scale - training 5× is prohibitively expensive; a single held-out set is standard, and with millions of examples its variance is fine.
- Time series - random folds leak the future into training. Use temporal splits: train on the past, validate on the future (walk-forward validation).
- Grouped data - if the same user/patient/document appears in multiple rows, split by group ID, or the model recognises entities instead of generalizing.
For LLM work the same discipline shows up as: held-out eval suites you don't train on, decontamination of pretraining data against benchmarks, and keeping a fresh, never-optimised-against eval for final go/no-go decisions - because prompt tuning against an eval overfits it exactly like hyperparameter tuning overfits a val set.
Worth sketching. The loop on the left and the single arrow into test is the whole point: one set is spent repeatedly, the other exactly once.
flowchart LR
A["All data"] --> B["Train split"]
A --> C["Validation split"]
A --> D["Test split, sealed"]
B --> E["Fit parameters"]
E --> F["Score on validation"]
C --> F
F -->|"change hyperparams, architecture,<br/>checkpoint, stopping point"| E
E --> G["Score on test, once"]
D --> G
What a good answer covers
- Three sets, three jobs: train fits parameters, validation drives all the choices you make between runs…
- Every decision you make while looking at a set "spends" it - tune against the test set enough times and…
- k-fold cross-validation (typically k=5 or 10) rotates the validation fold and averages, giving a…
- Use stratified k-fold for imbalanced classes so each fold preserves prevalence
- When CV is wrong or impractical
Key terms: train · validation · test · k-fold cross-validation · stratified · Deep learning at scale · Time series · Grouped data
In the glossary: Early stopping · Cross-validation
Interviewer follow-ups to expect
How does the same-user-in-both-splits failure actually look in the metrics?
What's nested cross-validation for?
How would you decontaminate an LLM eval set?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep