Tag: CV

  • MSD0021 Hashtag Video Relevance

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

  • MSD0018 Ads Policy Violation Detection

    Design an end-to-end ML system to detect ads selling weapons and other policy-violating goods on a large ads platform like Meta or Google Ads. Millions of new ad creatives arrive daily as text, images, and video, and advertisers constantly adapt their creative to evade detection. Google’s Ads Safety Report describes blocking or removing billions of ads per year, so this is an industrial-scale enforcement problem, not a one-off classifier.

    The system must block prohibited ads before they serve, route borderline cases to human reviewers, and keep the false-positive rate low enough that legitimate advertisers are not churned.

    How would you design this system? Cover the multimodal detection model, the human-review queue prioritization, the adversarial adaptation problem, and how you measure recall and precision at platform scale.

    Line-art scene: a stack of text, image, video, and carousel ad creatives feeding a gate that must decide allow or block before the first impression, with one path serving millions of impressions and the other path never allowed to serve

    The Problem: millions of new creatives arrive every day, roughly one in ten thousand is a prohibited-goods listing, and the decision must be made before the ad is shown even once.

    Answer

    The design is a pre-serve multimodal gate inside the ad-ingestion path. A cheap first stage kills known-bad creatives by hash and embedding near-duplicate lookup, then a shared vision-language encoder with per-policy heads scores every creative (ad copy, OCR text, landing-page text, image, video keyframes) before the first impression. Each policy class gets three calibrated bands: auto-block, human review, allow. Two decisions carry the design. First, thresholds are set from the asymmetric cost of a served weapon ad versus a wrongly blocked advertiser, per policy and per locale, rather than from a single global score cut. Second, the whole system is treated as an adversarial loop where the time from a new evasion pattern to a deployed block (hours, not quarters) matters more than static offline AUC.

    (1) Staged Funnel: creative-hash cache and embedding kNN against known violations resolve most repeat traffic in milliseconds; only novel creatives pay for the full multimodal pass.
    (2) Multimodal Model: a frozen vision tower plus a multilingual text tower over copy, OCR, ASR, and landing-page text, fused into multi-label per-policy heads instead of one binary “violating” output.
    (3) Three-Band Decision Policy: per-policy calibrated thresholds split traffic into auto-block, review, and allow, so precision on the auto-block band is protected by construction.
    (4) Expected-Harm Review Ranking: the reviewer queue is sorted by violation probability times forecast impressions times policy severity, not by score alone, and clusters of near-duplicate creatives collapse into one decision.
    (5) Adversarial Response Loop: evasion signals (re-upload similarity, account bursts, appeal patterns) feed hard-negative mining, an embedding blocklist hotfix within hours, and account-level enforcement that raises the attacker’s cost.
    (6) Measurement by Sampling: recall is estimated from stratified random audits of allowed traffic, precision from reviewer audits of blocks and from appeal-overturn rates.

    Pipeline: ad ingest, asset extraction with OCR and ASR, encoders, fusion head with per-policy scores, decision policy fanning out to allow-and-serve, auto-block, and a review queue; reviewer labels loop back through a label store into retraining, with a near-duplicate index feeding the decision

    Figure 1: Ingest → asset extraction → encoders → per-policy scores → three-band decision, with reviewer labels and the near-duplicate index closing the loop back into the model.

    Clarify Before Designing:
    (1) Scale and Asset Mix: how many new creatives per day, how many assets each, and what share is video (video dominates compute cost)?
    (2) Enforcement SLA: must an ad go live within minutes of upload, or is holding a creative for a deep asynchronous pass acceptable?
    (3) Policy Taxonomy: how many prohibited-goods classes, which are legally mandated, and how much do they vary by jurisdiction?
    (4) Cost Asymmetry: what is the tolerated false-block rate before advertiser churn becomes the bigger loss, and what is the appeal SLA?
    (5) Review Capacity: how many reviewer hours per day, in which languages, and with what accuracy on gold sets?
    (6) Label Availability: do we have historical enforcement decisions, appeal outcomes, and account-level history, or are we starting from policy text only?


    Login to view more content
  • DL0192 Depth Anything 3 Cross-View Depth Estimation

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

  • DL0184 Structure from Motion with Deep Learning

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

  • DL0182 Semantic, Instance, and Panoptic Segmentation

    What are the differences between Semantic, Instance, and Panoptic Segmentation, and when is each task formulation used in practice, for example inside an autonomous-driving perception stack?

    Question card showing a front-camera frame with 20,000 frames to annotate. It feeds three label-format options (semantic, instance, panoptic) and then three downstream driving modules: a free-space module, a vehicle tracker, and a motion planner, each joined by an arrow marked with a question mark.

    The Problem: A driving-perception team has budget to annotate 20,000 front-camera frames once, and three downstream modules each ask for the labels in a different shape. These are a free-space module that only asks which pixels are drivable, a vehicle tracker that must follow each car across frames, and a motion planner that wants one map telling it both whether a pixel is drivable and which vehicle it belongs to. Which segmentation formulation should feed each module, and how do the three formulations actually differ?

    Answer

    The three tasks differ in what a label is allowed to be. Semantic segmentation assigns every pixel exactly one class out of K and has no notion of object identity, so two touching cars collapse into a single connected “car” region. Instance segmentation does the opposite: it detects and masks each countable object separately with a confidence score, but it only covers thing classes, ignores amorphous stuff such as road, sky, and vegetation, and its masks may overlap each other or leave pixels uncovered. Panoptic segmentation is the union of the two: every pixel receives one pair (c_p, z_p) of class plus instance id, stuff classes get a single segment with no id, things get one segment per object, and the output is a strict partition of the image with no overlaps and no unlabeled pixels except an explicit void region. Which formulation you pick follows the consumer of the output, not fashion. A planner that needs to count and track individual vehicles needs ids, whereas a free-space or sky-replacement module only needs a region mask.

    (1) Label Space: semantic returns a class per pixel, instance returns a set of scored binary masks with classes, and panoptic returns a class plus an id per pixel.
    (2) Things Versus Stuff: instance segmentation is defined only on countable things; semantic segmentation handles both but cannot separate two instances; panoptic handles both and separates instances.
    (3) Overlap Constraint: instance masks are independent and can overlap, while panoptic forces a non-overlapping partition, which means any fusion of two heads must resolve conflicts explicitly.
    (4) Metrics Differ In Kind: semantic uses mIoU, instance uses mask AP averaged over IoU thresholds and scores, and panoptic uses PQ at a single fixed matching threshold with no score sweep.
    (5) Annotation Cost: stuff-only masks are cheap polygon paint, per-instance boundaries between adjacent same-class objects are the most expensive labels in the dataset.
    (6) Practical Selection: use semantic for region questions, instance for counting and tracking, and panoptic when a downstream module needs one consistent scene interpretation per pixel.

    Three panels showing the same toy scene of sky, road, two touching cars, and a person labeled three ways: semantic where both cars form one car region, instance where only the two cars and the person get scored masks that slightly overlap while sky and road are ignored, and panoptic where every pixel receives one class plus instance id with the two cars separated by a hard boundary

    Figure 1: One scene, three label spaces. The interesting pixels are the ones on the boundary between the two touching cars: semantic segmentation is structurally unable to place that boundary, instance segmentation places it but may let the two masks overlap and says nothing about road or sky, and panoptic segmentation is required to place it and to label every remaining pixel exactly once.

    In practice the formulation is chosen by the consumer. Free-space and drivable-area estimation, land-cover mapping from satellite imagery, portrait or sky matting, and organ or tumor delineation are region questions, so semantic segmentation is sufficient and its cheaper labels are a real advantage. Counting, tracking, and grasping are identity questions: counting cells in a microscopy image, tracking each pedestrian across frames, or picking one item out of a bin all require per-object masks, so instance segmentation (or its video extension) is the right task. Panoptic segmentation earns its extra cost when a single downstream consumer must be handed one coherent interpretation of every pixel, which is why it is the natural output format for driving perception and robot scene understanding, where the same map must answer both “is this pixel drivable” and “which vehicle is this”. A useful diagnostic question is whether two adjacent objects of the same class must ever be told apart. If the answer is no, panoptic annotation is money spent on a distinction nobody reads.

    Mathematical Formulation:
    f_{\mathrm{sem}}(p) = c_p
    f_{\mathrm{ins}} = \{(m_j, c_j, s_j)\}_{j=1}^{M}
    f_{\mathrm{pan}}(p) = (c_p, z_p)
    \mathrm{mIoU} = \frac{1}{K}\sum_{k=1}^{K}\frac{TP_k}{TP_k + FP_k + FN_k}
    \mathrm{PQ} = \mathrm{SQ} \times \mathrm{RQ}
    \mathrm{SQ} = \frac{1}{|TP|}\sum_{(g,q) \in TP}\mathrm{IoU}(g,q)
    \mathrm{RQ} = \frac{|TP|}{|TP| + \frac{1}{2}|FP| + \frac{1}{2}|FN|}

    Where:

    • p is a pixel, c_p its class, and z_p its instance id, which is undefined (shared) for stuff classes and unique per object for thing classes.
    • K is the number of classes, split into disjoint thing and stuff subsets by the dataset definition rather than by the model.
    • m_j is the j-th predicted binary mask, c_j its class, and s_j its confidence; the M masks are independent, so they may overlap and their union need not cover the image.
    • TP, FP, and FN in PQ count segments, not pixels, with a ground-truth segment g and a prediction q matched when \mathrm{IoU}(g,q) > 0.5; that threshold makes the matching provably unique because panoptic segments cannot overlap.
    • \mathrm{SQ} is segmentation quality, the mean IoU of matched pairs, and \mathrm{RQ} is recognition quality, the F1 score over segments; PQ is reported per class and then averaged, and often split into \mathrm{PQ}^{\mathrm{th}} and \mathrm{PQ}^{\mathrm{st}}.
    • TP_k in mIoU counts pixels of class k, which is why mIoU is blind to how many objects a class region contains.

    Worked Example (One Image):
    \mathrm{SQ} = 3.10 / 4 = 0.775
    \mathrm{RQ} = 4 / (4 + 1 + 1) = 0.667
    \mathrm{PQ} = 0.775 \times 0.667 = 0.517

    Four matched segments whose IoUs sum to 3.10 give an SQ of 0.775, and two false positives plus two false negatives each contribute a half count to the RQ denominator, so RQ is 0.667 and PQ lands at 0.517. The decomposition is the practically useful part: a high SQ with a low RQ means the masks are accurate but segments are being missed or hallucinated, which points at the classification and duplicate-removal path, while a high RQ with a low SQ means the right objects are found with sloppy boundaries, which points at output resolution and boundary supervision.

    Diagram of panoptic quality computation with a left column of six ground-truth segments and a right column of six predicted segments, arrows joining four matched pairs labeled with IoU values 0.92, 0.81, 0.74 and 0.63, a red dashed pair at IoU 0.38 that fails the threshold and counts as both a false positive and a false negative, one unmatched ground-truth sky segment, one spurious truck prediction, and a side panel computing SQ 0.775, RQ 0.667 and PQ 0.517

    Figure 2: PQ is a segment-level bipartite matching followed by a product of two interpretable factors. The pair at IoU 0.38 is the detail that separates candidates who have read the metric from those who have not: it is not a weak match, it is no match at all, and it is charged once as a false positive and once as a false negative.

    PropertySemanticInstancePanoptic
    Output per pixelOne class idZero, one, or several scored masksExactly one (class, instance id) pair
    Stuff classesCoveredNot part of the taskCovered as one segment per class
    Separates same-class objectsNoYesYes, and mandatory
    Overlapping masksImpossible by constructionAllowed and commonForbidden, conflicts must be resolved
    Standard metricmIoU over pixelsMask AP swept over IoU and scorePQ = SQ x RQ at IoU above 0.5
    Classic architectureFCN, DeepLab, per-pixel softmaxMask R-CNN, box then mask headPanoptic FPN, or mask-classification with queries
    Typical useFree space, land cover, matting, organ delineationCounting, tracking, robotic graspingDriving and robot scene understanding, one map for all consumers

    Login to view more content
  • DL0162 World Model Object Permanence

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

  • DL0158 3D-Aware World Model Geometry

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

  • DL0157 VLA Zero-Shot and Few-Shot Transfer

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

  • DL0156 Force-Torque and Visual Fusion in VLA

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

  • DL0142 OCR-Free Document VLM

    How do OCR-free Document VLMs process complex multi-column PDFs, tables, and infographics compared to multi-stage OCR pipeline setups?

    Question card for Ledgerline's document intake team. It shows three sketched page types (a two-column report split by a full-width figure caption, a borderless rate table with a spanning header, and an infographic with bars, a legend and a dashed series), each with an open question beneath it, and a choice between a multi-stage OCR pipeline and an OCR-free Document VLM.

    The Problem: Ledgerline’s document team must pick one parser for a 12,000-page intake batch that mixes two-column research reports, borderless rate tables with spanning headers, and chart-heavy infographics, all feeding an LLM that answers analyst questions. Should they chain OCR, layout and table models, or hand the raw pages to an OCR-free Document VLM?

    Answer

    A multi-stage pipeline turns a page into a text document before any reasoning happens: rasterize → detect text regions → recognize each crop → classify layout blocks → sort them into reading order → recover table cell structure → serialize to Markdown or HTML → feed a text LLM. An OCR-free Document VLM deletes that entire chain and treats the page as an image: a dynamic-resolution ViT encoder cuts the raster into 14×14 patches, a 2×2 pixel-shuffle merge collapses them into one visual token per 28×28 pixel block, and a decoder-only LLM attends over those tokens to emit the answer, the Markdown, or the HTML table directly. The consequence is that self-attention itself becomes the layout model: column boundaries, cell alignment, chart axes, and legend-to-series association are learned from pixels rather than reconstructed by six independently trained components whose errors multiply. What you gain is robustness on infographics and rotated or borderless tables, where reported scores such as Qwen2.5-VL-72B’s roughly 96 ANLS on DocVQA and roughly 87 on InfographicVQA are far out of reach for a serialized-text pipeline. What you lose is character-level coordinates, per-token confidences, and cheap per-page cost, because a single A4 page at 150 DPI already costs about 2,835 visual tokens and the prefill over them is quadratic.

    (1) Pixels In, Structure Out: the model never sees a text layer, so scanned pages, screenshots, and born-digital PDFs with broken embedded fonts all take the identical path.
    (2) Dynamic Resolution Tokenization: instead of squashing every page to 224×224, the encoder keeps native aspect ratio and resolution, so an 8 pt footnote survives as its own tokens rather than being blurred away.
    (3) Attention Replaces The Reading-Order Module: a three-column paper needs no LayoutReader-style sorter, because the decoder learns column continuation the way a language model learns syntax.
    (4) Tables As Generated Markup: structure recognition becomes ordinary autoregressive decoding of HTML or Markdown, which handles borderless and spanning cells but has no per-cell confidence.
    (5) No Error Compounding, No Coordinates: the pipeline’s five or six stages multiply their error rates, while the VLM has one loss and one failure surface but cannot tell you where on the page an answer came from.
    (6) Token Budget Is The Real Constraint: visual tokens grow with the square of DPI, so resolution, tiling, and page count trade directly against context and O(N^2 d) prefill.

    Two horizontal lanes compared on the same rasterized page: the upper lane shows a six-stage OCR pipeline running text detection, crop recognition, layout analysis with reading order, table structure recognition, and Markdown serialization into a text LLM, annotated with compounding per-stage error; the lower lane shows an OCR-free VLM with a dynamic-resolution ViT patch encoder, a 2x2 pixel-shuffle merge producing 2,835 visual tokens, and a decoder-only LLM emitting the answer or an HTML table

    Figure 1: The same pixels, two failure surfaces. The pipeline produces an intermediate text document with coordinates that any downstream model can consume and any auditor can overlay, at the cost of five models whose accuracies multiply. The VLM is one differentiable stack with one loss, and its output carries no character boxes at all unless the model was explicitly trained to emit them.

    The three hard document classes fail differently. On multi-column PDFs, a pipeline’s mistake is almost never recognition, it is serialization: a two-column paper with a full-width figure caption in the middle gets flattened into interleaved half-sentences, and the LLM downstream has no way to recover the intended order because the evidence, the geometry, was discarded. On tables, borderless layouts and spanning header cells break rule-based and detection-based structure recognition, whereas a VLM trained on HTML targets can emit rowspan and colspan because it saw the whole grid at once. On infographics and charts, OCR returns a bag of strings with no relations, so “which bar is tallest” or “what does the dashed series do after 2021” is unanswerable from the transcript; this is precisely where the ChartQA and InfographicVQA gaps are widest. The pipeline still wins wherever the requirement is verbatim fidelity plus provenance, since a hallucinated digit inside a generated table cell is indistinguishable from a correct one, while a low-confidence OCR crop announces itself.

    Mathematical Formulation:
    N_{tok} = \lceil H/p \rceil \times \lceil W/p \rceil
    N_{tok} = 63 \times 45 = 2835
    C_{prefill} = O(N_{tok}^2 d)
    A_{pipe} = \prod_{k=1}^{K} a_k
    A_{pipe} = 0.95^5 \approx 0.77

    Where:

    • N_{tok} is the number of visual tokens the encoder emits for one page, which is what actually enters the LLM context.
    • H and W are the rasterized page height and width in pixels (1754 \times 1240 for A4 at 150 DPI), and p = 28 is the effective patch stride after a 2×2 merge of 14×14 patches.
    • C_{prefill} is the attention cost before the first output token, quadratic in N_{tok} and linear in model width d; the KV cache grows linearly, so a 20-page document is a memory problem as well as a compute one.
    • a_k is the per-page success rate of pipeline stage k and K the number of stages, with k \in \{1,\ldots,K\} running detection, recognition, layout, reading order, and table structure.
    • A_{pipe} is the end-to-end page accuracy: five stages that each succeed 95% of the time leave only about 77% of pages fully clean, and this multiplicative compounding is the structural argument for a single-stage model.
    Log-scale chart of tokens per A4 page versus rasterization DPI from 72 to 420: a curve for visual tokens after 2x2 pixel-shuffle merge rising quadratically from about 640 at 72 DPI to about 21500 at 420 DPI, a four-times-higher curve for raw 14x14 patches without merging, and a flat line at about 800 tokens for serialized OCR text, with a horizontal marker at the 16384-token per-image cap and a vertical dashed line at 150 DPI

    Figure 2: Resolution is the cost knob. The same A4 page costs 2,835 visual tokens at 150 DPI and 11,214 at 300 DPI, roughly 4x the tokens and 16x the prefill FLOPs, while a serialized OCR transcript of that page stays near 800 tokens whatever the DPI. The 2×2 pixel-shuffle merge is what keeps a full page under the common 16,384-token per-image cap at all.

    PropertyMulti-stage OCR pipelineOCR-free Document VLM
    Multi-column reading orderExplicit sorter over layout blocks; interleaves columns when a full-width element splits the pageLearned implicitly by attention over the whole page at once
    TablesDedicated structure model emitting cell boxes; weak on borderless and spanning cellsGenerates HTML with rowspan and colspan; can silently drop or invent rows in long tables
    Charts and infographicsReturns unrelated strings; visual relations such as legend-to-series are lostReads axes, bar heights, and legends jointly, which is where the accuracy gap is largest
    ProvenanceCharacter and word boxes plus per-crop confidence, usable for redaction and highlightingNone by default; needs grounding training to emit absolute coordinates
    Dominant failure modeCompounding stage errors and serialization scrambling; degrades visiblyFluent hallucination and repetition loops; degrades invisibly
    Cost per pageSmall CNN and CTC models, CPU-viable, millions of pages per day cheaplyThousands of visual tokens through a multi-billion-parameter decoder with quadratic prefill
    Adapting to a new form typeRetrain or rewrite whichever stage broke, with per-stage labelsFine-tune once on image and target-string pairs, no intermediate annotation

    Login to view more content