This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
Tag: Data Eng
MSD0029 Food Calorie Estimation
Design a model that estimates the calorie and macronutrient content of a meal from a single photo, as used by apps like MyFitnessPal, Calorie Mama, or Lose It. The user snaps a photo of their plate. The model must identify the dishes, estimate portion sizes from a 2D image with no depth cue, look up or predict per-gram nutritional values, and return a calorie estimate within a few seconds.
The core technical challenge is portion estimation: a single 2D photo carries no metric depth, so converting pixel area into grams requires a mechanism assumption. The model must also handle a long tail of cuisines and homemade dishes that match no packaged-food database, varying plating and lighting, and the inherent ambiguity of judging a portion from one viewpoint.
How would you design this model? Cover the candidate portion estimation approaches (monocular depth estimation, reference-object scaling, semantic segmentation with food-class density priors, and direct end-to-end calorie regression), how you handle the long tail of homemade and mixed dishes, how you generate training labels at scale when ground-truth portion weights are scarce, and how you calibrate and communicate uncertainty when a single 2D photo is inherently ambiguous.

The Problem: the same mask area can be a thin layer or a tall mound, so one photo maps to a wide range of grams before any model has made a single assumption explicit.
Answer
The design is a segmentation-conditioned multi-task regressor. One shared backbone emits per-dish instance masks, a relative depth map, and a direct per-region regression of grams, calories, and macronutrients, with the physical volume-times-density estimate retained as a parallel sanity check rather than as the primary predictor. Google’s Nutrition5k study drives that ordering: an end-to-end regressor from a single RGB view reaches roughly 26% mean calorie error, and feeding depth, either as an extra channel or as a depth-derived volume scalar, cuts that error substantially, which is why depth is an auxiliary input to the regressor here rather than the front end of a separate segment-then-volume-then-density-lookup chain. Two decisions are pivotal. First, scale is treated as a learned prior anchored by plate and utensil geometry, not as metric information that a single RGB frame secretly contains. Second, the output is a calibrated interval and an editable suggestion, because one viewpoint leaves real ambiguity that no architecture removes.
(1) Monocular Depth Volume: predict per-pixel depth, fit the plate plane, and integrate height over each mask to get volume, then multiply by a food-class density. Physically interpretable, but scale-ambiguous.
(2) Reference-Object Scaling: use a known-size object in frame (bank card, coin, thumb, standard plate rim) to fix millimeters per pixel in the plate plane, which pins down area but not height.
(3) Segmentation With Density Priors: multiply mask area by a learned per-class height prior and a tabulated density in grams per cubic centimeter from food-composition data. Cheapest to build and to explain.
(4) Direct End-to-End Regression: regress grams, kilocalories, and macros straight from region features, letting the network learn scale from plate, cutlery, and hand context. Most accurate where labels exist, least interpretable.
Figure 1: The mechanism: photo → masks and depth → grams per dish, with the physical volume path acting as a guardrail on the learned regressor and a conformal step turning the point estimate into a range.
Clarify Before Designing:
(1) Label Ground Truth: do we have any scale-weighed dishes with per-ingredient masses, or only crowd labels and user-entered corrections?
(2) Capture Protocol: is it strictly one top-down snap, or may we request an oblique angle, a second frame, or a reference object without destroying adoption?
(3) Depth Sensors: what fraction of devices expose LiDAR or ARKit/ARCore depth, which turns scale from a guess into a measurement?
(4) Accuracy Bar: what calorie error is product-acceptable, and does the UX accept a range plus an edit control instead of one number?
(5) Coverage And Budget: which cuisines dominate traffic, what share of meals is packaged or restaurant food with known nutrition, and is inference on-device or server-side?Login to view more contentMSD0027 Fake Account Bot Detection
Design a system to detect fake accounts and bots on a social network like Facebook, Twitter/X, or Instagram. Fake accounts power spam, coordinated inauthentic behavior, follower farming, and political manipulation, and their operators evolve constantly: they buy aged accounts with real history, use LLMs to write bios and mimic human posting cadence, and route traffic through residential proxies so IP reputation says nothing.
The system must score accounts at creation time and keep re-evaluating them as behavior develops, while holding the false-positive rate low enough that real users are not wrongly suspended, and routing the highest-risk cases to human investigators.
How would you design this system? Cover the account-level feature signals (registration, graph, content, behavior), the detection model architecture, how you handle adversarial evolution, the human-in-the-loop review queue, and how you measure precision and recall when ground truth is scarce.

The Problem: millions of new accounts a day, a farm that can forge everything cheap to forge, and one real person sitting in the same batch. Decide who to trust without suspending them.
Answer
Treat this as two coupled problems running at two speeds. At signup, a low-latency gradient-boosted scorer over registration, device, and infrastructure features decides whether the account starts with friction, and a continuous re-scoring layer then re-judges every live account as its graph and behavior accumulate. That second layer is where the real detections happen: a relational GNN over the follow and friend graph plus unsupervised synchrony clustering (the SynchroTrap idea of co-clustering accounts that act on the same targets in the same time buckets) catches campaigns whose individual members each look perfectly human. Scores never map directly to bans. They map to a graduated enforcement ladder (allow, challenge, limit reach, human review, disable) so the expensive mistake, suspending a real user, requires either overwhelming cluster-level evidence or an investigator.
(1) Two-Speed Detection: a synchronous per-signup scorer under a 200 ms budget, plus a daily (and event-triggered) batch pass over every active account, since most fake accounts only reveal themselves after they start acting.
(2) Cluster-Level Evidence: the decision unit is the account and the campaign; graph plus action-synchrony clustering finds coordinated groups without needing labels for the new tactic.
(3) Cost-To-Forge Feature Weighting: prefer signals an operator must pay real money or real time to fake (device integrity, aged organic graph, human-only interaction telemetry) over signals a proxy or an LLM erases for free.
(4) Graduated Enforcement: friction first (phone or CAPTCHA challenge, reach limiting), auto-disable only in the top band with corroboration, always with an appeal path that feeds labels back.
(5) Label Machinery: reviewer verdicts, appeal reversals, honeypot and test-buy cohorts, and a random-audit stream, because production has no clean ground truth and the flagged sample alone teaches the model its own blind spots.
Figure 1: Two speeds, one policy: a synchronous scorer at signup, a daily graph and synchrony pass over every live account, and a ladder whose top band ends at a human, not a model.
Clarify Before Designing:
(1) Scale And Prevalence: how many signups per day, how many active accounts to re-score, and what does the current prevalence estimate say (a few percent of MAU)?
(2) False-Positive Budget: how many wrongly restricted real users per day is the product willing to accept, and is auto-suspension allowed at all under the platform’s appeal and regulatory commitments?
(3) Enforcement Surface: can we impose signup friction (phone verification, CAPTCHA), or does growth own that decision and force us to detect after the fact?
(4) Review Capacity: how many investigator-hours per day exist, in which languages and regions, and what is the target queue latency for high-harm cases?
(5) Threat Priority: which abuse type pays first, follower farms, spam, or coordinated political campaigns, since they differ in scale, sophistication, and tolerance for delay?
(6) Signal Access: what device, telemetry, and payment signals are legally usable per region, and how long may we retain them?Login to view more content





