Tag: NLP

  • MSD0095 LLM Judge Meta-Evaluation

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0094 Incident Investigation Agent

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0093 Answer Engine Citations

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0092 LLM Streaming Failover Resume

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0091 Multitenant AI Receptionist

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0090 Realtime Voice Agent

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0088 Query Autocomplete Model

    Design the model that powers query autocomplete for a search box serving 500,000 queries per second at p99 under 50 milliseconds. Given a typed prefix, the system must return the top-5 most useful completions, balancing the most-likely intent, personalization (a user who just searched flights gets travel completions), freshness (trending queries decay in hours), and spell tolerance for noisy prefixes.

    The two main mechanism families pull in opposite directions: a compiled trie / finite-state machine is nearly free at runtime but has no learned generalization, while a neural sequence model generalizes but costs inference time you may not have.

    How would you design this mechanism? Cover the candidate generation choice (weighted FST / trie vs a small generative model, and whether a hybrid earns its keep), the ranking signals (historical popularity, time-decayed trending, session personalization) fitted into the 50ms budget, personalization that does not destroy cacheability, noisy-prefix tolerance, and how the model learns from impression-to-completion logs that are position-biased.

    Line-art scene: a person types the prefix ho into a search box whose dropdown holds five empty slots marked with question marks; cards for a recent session about flights to tokyo, a trending query that fades in hours, and a noisy prefix point at the slots, with 500,000 requests per second and p99 under 50 ms annotated

    The Problem: every keystroke is a request, 500,000 of them per second, and each must fill five slots in under 50 ms while weighing what most people mean, what this user was just doing, what is trending right now, and what the user meant to type.

    Answer

    The mechanism is a hybrid with a strict division of labor. A compiled weighted FST generates candidates in microseconds for every prefix the logs have seen, and a small mutable trend index injects queries that spiked in the last few hours. A small neural language model runs only as a fallback when the prefix is too rare to yield five candidates. A learned ranker then orders about 50 candidates using historical popularity, time-decayed trend counts, and session features, and it is applied after a cache keyed only by prefix and locale, so personalization never destroys cacheability. The ranker trains on impression logs with inverse-propensity weighting, using propensities measured by small randomized position swaps, so it learns relevance instead of slot order.

    (1) Weighted FST / Trie: a minimal automaton compiled from historical queries in which every node stores its subtree’s best weight or a precomputed top-k list, so a prefix walk returns the top completions in time proportional to the prefix length.
    (2) Small Generative LM: a character or subword decoder conditioned on the prefix (and optionally the session) that beam-searches completions, including strings never seen in the logs.
    (3) Hybrid Retrieve-Then-Rank: the FST plus a fresh trend index produce candidates, a learned ranker reorders them with session features after a shared cache, and the generator is invoked only for long-tail prefixes.

    Hybrid autocomplete mechanism: typed prefix enters a shared cache keyed by prefix and locale; on a miss, a candidate generation group with a static weighted FST, a fresh trend index, and a neural LM fallback fills the cache; about 50 candidates flow to a learned ranker fed by a session store, which outputs the top-5; impression logs feed IPS retraining of the ranker

    Figure 1: The hybrid mechanism: a shared cache keyed by prefix and locale, a static FST plus a fresh trend index on cache misses, a neural fallback when fewer than 5 candidates exist, and a learned ranker that adds session features after the cache and retrains on IPS-weighted impression logs.

    Clarify Before Designing:
    (1) Latency Definition: is 50 ms a server-side p99 or client-perceived including the network, and does the client debounce keystrokes and cancel stale requests?
    (2) Prefix Coverage: what share of keystroke prefixes appears in the last 90 days of logs? That number decides how often a generator is needed at all.
    (3) Serving Hardware: is the fleet CPU-only, or are GPUs available in the serving region for a neural path?
    (4) Personalization Scope: may we use logged-in search history, or only in-session signals under privacy limits?
    (5) Freshness SLA: must a breaking query appear within minutes, or is next-day acceptable?
    (6) Input Noise and Scripts: how noisy is mobile typing, and do we serve languages with input-method composition (CJK) or transliteration?


    Login to view more content
  • MSD0087 Async RL Post-Training

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0085 Semantic ID Recommendation

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0080 Content Moderation System

    Design a content moderation system for a platform where users post 500 million text/image/video items per day. Policy-violating content (hate, harassment, adult, violence, misinformation) must be caught fast: some removed instantly, some routed to human reviewers. Legitimate edgy content must not be over-removed (press freedom, satire, news).

    Reviewer capacity is fixed at thousands of decisions per hour, so the system must triage: auto-action on confident cases, queue the rest by expected harm. Labels trickle in over days, policies change monthly, and adversarial posters constantly adapt (coded language, image perturbations).

    How would you design this system? Cover the multi-stage classifier cascade (cheap model, expensive model, human), the triage queue that ranks by expected harm and review value, the thresholding policy that trades precision for recall per content class, label collection and the reviewer-agreement loop, evaluation that reflects asymmetric costs (missed CSAM vs removed satire), and the adaptation cycle for policy changes and adversarial drift.

    Line-art scene: a stream of text, image, and video posts plus a news and satire card converges on a single question mark, a poster holds a card with a coded word, and three human reviewers stand on the right labeled with a few thousand decisions per hour

    The Problem: half a billion posts a day meet a few thousand human decisions an hour, and the same image can be a violation, a news report, or a joke.

    Answer

    The design is a three-stage cascade that feeds a harm-ranked review queue. Known-bad media is blocked by perceptual hash matching before any model runs. A distilled per-modality model then scores every item, and only the uncertain ~5% escalates to a heavy multimodal model that reads the whole post. Each policy class applies its own three-action rule (remove, review, leave), with thresholds derived from the cost of a wrongful removal, the cost of a miss, and the price of a reviewer’s decision. The queue is ordered by probability times severity times predicted reach, and reviewer decisions, audits, and appeals flow back as labels that retrain the models weekly.

    (1) Hash Match First: known CSAM and terrorist media is matched against perceptual-hash banks and blocked instantly, with mandatory reporting, so no model error can let it through.
    (2) Cheap-Then-Expensive Cascade: a distilled model scores 100% of uploads in ~40 ms, and only items in an uncertain region escalate to a heavy whole-post multimodal model.
    (3) Per-Class Three-Action Thresholds: each class gets its own remove, review, and leave bands computed from its cost asymmetry, so CSAM and satire are never judged by the same cutoff.
    (4) Harm-Ranked Triage Queue: reviewers see items in order of calibrated violation probability times severity times predicted reach, plus a small label-value bonus.
    (5) Reviewer Agreement Loop: blind second reviews measure per-policy agreement, disagreements go to expert adjudication, and the adjudicated gold set weights every reviewer’s labels.
    (6) Fast Adaptation Cycle: a policy-prompted LLM classifier bootstraps labels for new policy clauses within days, and weekly hard-example mining keeps pace with coded language and perturbed images.

    Moderation pipeline: uploads pass hash matching, which blocks and reports known-bad media; a cheap model scores all items and settles about 95 percent, the heavy whole-post model scores the uncertain 5 percent, per-class thresholds split traffic into auto-action and a harm-ranked review queue, human review produces labels, and a dashed retraining path returns to the cheap model

    Figure 1: The moderation path: hash hits are blocked outright, the cheap model settles ~95% of items, the heavy model scores the uncertain rest, and per-class thresholds split traffic into auto-action and a harm-ranked queue whose decisions retrain the models.

    Clarify Before Designing:
    (1) Modality and Language Mix: what share of uploads is text, image, and video, and how many languages need native-speaker reviewers? Video and low-resource languages drive both cost and recall gaps.
    (2) Pre- or Post-Publication: which classes must be blocked before anyone sees them, and how much latency may the upload path absorb? This sets the synchronous budget.
    (3) Cost Asymmetry and Law: which classes carry legal duties (CSAM reporting, takedown deadlines under laws like the EU DSA), and how does the business price a wrongful removal of news against a miss?
    (4) Reviewer Capacity: exactly how many decisions per hour, split across which languages and specialties, and can surge capacity be bought during crises?
    (5) Label Sources: do user reports, an appeal flow, and any random-sample labeling exist today, or only decisions on items a model already flagged?
    (6) Reach Signals: can an item’s likely audience (follower count, early engagement velocity) be predicted at scoring time? Without it the queue cannot rank by harm.


    Login to view more content