The interview problem
A classifier must adapt to a new customer using five labeled examples per class. Explain how learning an initialization for fast adaptation differs from ordinary pooled training. Derive a one-step meta-gradient, identify what a first-order approximation drops and design an evaluation that does not leak new-customer labels.
Original ML-fundamentals practice, not a reported company interview. Numerical examples are hypothetical. Primary research retrieved September 27, 2026; interview date not applicable.
1. Define the task distribution
A task is a prediction problem with its own small adaptation dataset and evaluation examples. In this scenario, tasks might be customers sharing a compatible label ontology but differing in vocabulary and document distribution. Define whether new classes also appear; adapting to a new domain and learning a new label set are different evaluation problems.
Within each task, call the adaptation examples the support set and the held-out examples the query set. Across tasks, separate meta-training, validation and test tasks. The desired generalization is to a new task after a fixed adaptation budget, not merely to another row from a customer already used to optimize the initialization.
Task construction is part of the model. If training tasks are arbitrary random slices of one homogeneous dataset, success may demonstrate ordinary interpolation rather than meaningful customer adaptation. Conversely, unrelated tasks can make a shared initialization a poor assumption. State which forms of variation the deployment is expected to contain.
2. Optimize performance after adaptation
Let θ be shared initial parameters. For task i, let Sᵢ(θ) be the support loss and Qᵢ(φ) the query loss evaluated at adapted parameters φ. One gradient step gives φᵢ=θ−α∇Sᵢ(θ), where α is the inner learning rate. The outer objective is the average query loss J(θ)=(1/T)ΣᵢQᵢ(φᵢ).
Pooled supervised training directly minimizes losses at one shared parameter vector. This objective instead evaluates parameters after a specified adaptation procedure. It can prefer an initialization that is not optimal before adaptation. At deployment, adaptation uses the new task's allowed support labels; query labels remain unavailable.
sample meta-training tasks
↓
split support and query examples within each task
↓
copy shared initialization → adapt on support loss
↓
evaluate adapted model on query loss
↓
differentiate average query loss back to initialization
↓
update shared initialization; discard task-specific copiesModel-Agnostic Meta-Learning is a primary example of this approach. Its name does not mean every model or task works equally well: the formulation relies on an optimization procedure that supports the required gradients. The practical benefit must be compared with simpler adaptation baselines.
3. Derive the one-step gradient
For a single task with twice-differentiable support loss and a fixed scalar α independent of θ, the Jacobian of φ with respect to θ is I−αHₛ(θ), where Hₛ is the support-loss Hessian. Applying the chain rule gives ∇θQ(φ)=(I−αHₛ(θ))ᵀ∇φQ(φ). For a twice continuously differentiable scalar-valued loss the Hessian is symmetric, but retaining the transpose makes the chain rule explicit.
A first-order approximation uses ∇φQ(φ) as the update direction for θ, dropping the dependence of the inner update on θ through the Hessian. It still adapts on support data and evaluates query data at the adapted parameters. It is not the same as evaluating the query loss before adaptation, and it is not generally the exact derivative of J.
Implementing the exact gradient does not require materializing a dense parameter-by-parameter Hessian. Automatic differentiation can compute the needed Hessian-vector products through the update. Memory and compute still depend on the number of unrolled steps, activations and the differentiation strategy.
4. Work a scalar example by hand
Take S(θ)=½(θ−2)², Q(φ)=½(φ−3)², θ=0 and α=0.25. The support gradient is −2, so φ=0−0.25(−2)=0.5. Query loss is ½(0.5−3)²=3.125. The query gradient at φ is −2.5, and the support Hessian is 1.
The exact meta-gradient is (1−0.25)(−2.5)=−1.875. The first-order direction is −2.5. With outer step size β=0.1, the exact update sets θ to 0.1875, while the first-order update sets it to 0.25. Both happen to improve this example, but their magnitudes differ; this calculation alone does not establish which method performs better on other tasks.
Expand the adapted parameter as φ=0.75θ+0.5. Then J(θ)=½(0.75θ−2.5)², whose derivative is 0.75(0.75θ−2.5). At θ=0 this is −1.875, independently confirming the chain-rule result. The minimum is θ=10/3, because one support step then lands at query optimum φ=3.
The support optimum is θ=2, yet the post-adaptation objective has optimum 10/3. That unusual difference is intentional in this toy construction: support and query losses have different centers. Real support/query sets should represent the declared task sampling process, not be engineered after seeing test labels.
5. Check limiting cases and unstable steps
For the same quadratic with α=0, φ=θ and the meta-objective becomes the query loss at the initialization. With α=1, every θ maps to φ=2 in one step. Query loss is therefore always ½, and the exact meta-gradient is zero. A first-order direction would be −1, which moves θ even though it cannot change the adapted result under these assumptions.
This is a useful diagnostic: ignoring the inner Jacobian can be misleading when adaptation removes sensitivity to initialization. For α greater than one in this example, the Jacobian is negative and can reverse the gradient direction. That does not mean every step above one is unstable; stability depends on curvature. Here support gradient descent converges for 0<α<2 when repeated indefinitely.
With several inner steps, the derivative passes through the sequence of update Jacobians. Their products can attenuate or amplify sensitivity. Tune adaptation length and learning rate on held-out validation tasks, and keep them fixed for the reported test. More inner steps can overfit tiny support sets rather than improve adaptation.
6. Test genuine adaptation rather than leakage
Hold out whole customers when claiming new-customer generalization. Deduplicate templates and source documents across splits. Fit shared preprocessing and representation statistics using permitted meta-training information. A new customer's query labels must not tune the inner learning rate, stopping point, prompt, class mapping or initialization.
Compare the same support examples and query examples across pooled pretraining plus fine-tuning, a frozen representation with a small classifier, training from scratch and the meta-trained initialization. Match adaptation steps, available labels and selection budget, or clearly explain differences. Report zero-step and adapted performance to show what adaptation adds.
For five examples per class and four classes, the support budget is twenty labels, not five total. Report class balance and how examples were selected. A balanced support set can be realistic for a curated onboarding process but may not represent randomly collected production labels.
Aggregate according to the deployment question. Equal weight per customer estimates performance for a uniformly selected customer in the evaluation population; pooling all query rows weights large customers more. If ten customers contribute one hundred queries each, there are one thousand query outcomes but only ten customer clusters for cross-customer uncertainty. Use a task-aware uncertainty analysis rather than pretending every row is independent.
Repeated random support draws measure sensitivity to the few examples supplied. Reset model parameters, optimizer state and mutable buffers such as normalization statistics between tasks so one test customer cannot train the next. If transductive use of unlabeled query inputs is allowed, state that explicitly and give baselines the same access; it changes the problem.
7. Keep adaptation bounded in deployment
Version the base initialization, adaptation recipe, support snapshot and resulting task-specific artifact. Limit which parameters adapt and cap steps, time and resource use. Validate support labels and permission scope; a malicious or mistaken support example can influence the adapted model even if the shared base is sound.
For forty tasks per meta-batch and five inner steps, there are two hundred task-step updates before query evaluations and outer differentiation. That is an operation count, not a precise multiple of ordinary training cost. Parallel tasks increase memory use; sequential accumulation requires correct averaging and isolation of task states.
Use a fallback when support data is absent, contradictory or out of the training task distribution. A robust shared model or human review may be better than forcing adaptation. Monitor gains by task slice, instability across support draws and regressions on important behaviors. Do not continuously incorporate customer corrections into a shared initialization without a separate approved learning process.
8. Trade-offs and interview follow-ups
Exact meta-gradients align with the specified unrolled objective but can be expensive. First-order methods reduce differentiation cost while changing the update. Adapting only a small head is simpler and cheaper but may miss representation shifts. A strong pooled representation can outperform a complex meta-learning system when task variation or few-shot evaluation is weakly defined.
Follow-ups: What changes when every task has different classes? How would you learn α rather than fixing it? What if support and query distributions differ? How do optimizer momentum states affect the derivative? What would demonstrate that gains come from extra compute rather than meta-training? How would you detect one customer's support data leaking into another customer's model?
9. Self-review rubric
- Define tasks, support/query sets and the intended task distribution.
- Distinguish the shared initialization from adapted task parameters.
- Apply the chain rule through the inner update and identify the omitted Hessian term.
- Verify the scalar example and explain the α=1 limiting case.
- Evaluate on held-out tasks with matched support and tuning budgets.
- Respect task-level uncertainty and reset adaptation state.
- Discuss compute, fallback behavior and simpler baselines.
Sources and related practice
Finn, Abbeel and Levine: Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks, ICML 2017, August 6–11, 2017. Primary background for learning parameters through an adaptation objective. The scalar examples, deployment scenario and evaluation calculations here are original.
Continue with gradient descent, data leakage and effective sample size.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.