skip to content

When monitoring a claims-triage model's 384-dimension text embedding for input drift, why does a separate score per dimension mislead, and what replaces it?

level: seniorimportance: should knowfreq 40%

answer

  1. 384 chances to cry wolf
  2. marginals miss changed correlations
  3. MMD: kernel, median bandwidth, permutations
  4. domain classifier: held-out AUC against 0.5
  5. reduce first: model outputs, PCA error

basics

~20 s

Per-dimension scores raise chance alarms across 384 coordinates unless corrected, and they miss shifts in how dimensions co-vary. Score the vectors jointly: MMD with a permutation null, a domain classifier's held-out AUC, or reduced views such as PCA reconstruction error.

solid answer

~50 s

Testing each of 384 dimensions at a 5% level flags about 19 on unshifted data if the tests were independent; Bonferroni (α / 384) fixes that but is conservative. Worse, a shift can change how dimensions co-vary while every marginal stays put, and a single encoder coordinate means nothing to act on. Replace it with joint scores. MMD with a Gaussian kernel, bandwidth at the median pairwise distance, compares whole point clouds; the unbiased estimate can be slightly negative, a permutation test supplies the null, and cost is quadratic, so subsample. A domain classifier trained to tell reference from live claims, scored by held-out AUC, reads 0.5 when they are indistinguishable, and its top-scored rows show which claims look new. Cheaper reductions: the model's own output distribution and PCA reconstruction error from components fit on the reference.

code

pseudocode · 12 lines
pseudocode
function domain_classifier_check(reference_rows, live_rows):
    reference_rows = sample(reference_rows, length(live_rows))
    rows = [(x, 0) for x in reference_rows] + [(x, 1) for x in live_rows]
    shuffle(rows)
    train, held_out = split_in_half(rows)
    model = fit_binary_classifier(train)
    scores = [predict_live_probability(model, x) for (x, label) in held_out]
    labels = [label for (x, label) in held_out]
    auc = roc_auc(scores, labels)            # about 0.5 when windows are indistinguishable
    live_held_out = [(s, x) for (s, (x, label)) in zip(scores, held_out) if label == 1]
    most_new = sort_descending(live_held_out)[0 .. 19]
    return auc, most_new                     # the live claims that look most unlike the reference

go deeper

for a junior

Recall that an embedding is checked as whole vectors, not coordinate by coordinate, and that a domain classifier's AUC of 0.5 means no detectable difference.

for a middle

Explain the multiplicity problem, the MMD formula with its kernel and permutation null, and how a held-out domain classifier is built and read.

for a senior

Choose and harden the check: median bandwidth, unbiased estimate, subsampling, leakage-free classifier inputs, and reading the top-scored claims to name the shift.

for a principal

Weigh cost against coverage for every embedding feature on a platform: cheap reduced views by default, a classifier or MMD where a joint shift would hurt.

## The setup A claims-triage model also reads the free-text loss description, turned into a fixed-length **embedding** — 384 numbers per claim — by a frozen text encoder. If claimants start describing losses differently (short, photo-referencing descriptions from a new mobile-app intake channel, say), the model's inputs have shifted even if no numeric or categorical feature moved, and a drift check should see it. ## Why one score per dimension misleads The tempting design treats each of the 384 coordinates as a numeric feature with its own PSI or two-sample test. It fails in three ways: - **Multiplicity.** Run 384 tests at a 5% significance level on unshifted data and, if they were independent, about 384 × 0.05 ≈ 19 flag per run on average. A **Bonferroni** correction — act only if some p-value falls below α / K = 0.05 / 384 ≈ 0.00013 — restores the overall error rate but is conservative, more so because the dimensions are correlated. - **Marginals miss joint change.** Two coordinates can keep their individual distributions while the way they co-vary changes, so the descriptions occupy a different region of the space. Every per-dimension score stays flat while the cloud of points has moved. - **Coordinates mean nothing alone.** Dimension 217 of an encoder has no interpretation, so even a true per-dimension alarm gives nothing to act on. Per-dimension tests are not useless: one large comparison on image benchmarks (Rabanser et al.) found Bonferroni-aggregated univariate tests on a **reduced** representation comparable to multivariate tests. Uncorrected, on raw coordinates, they mostly report noise. ## MMD: comparing whole clouds of points **Maximum mean discrepancy (MMD)** compares two samples of vectors through a kernel `k`: `MMD² = E k(x, x′) + E k(y, y′) − 2 E k(x, y)` with x, x′ drawn from the reference and y, y′ from live. With a **characteristic** kernel such as the Gaussian, MMD is zero only when the two distributions are equal. - **Bandwidth.** The Gaussian kernel's width is commonly set to the **median pairwise distance** in the pooled sample. It matters: the empirical MMD shrinks toward zero both as the width goes to zero and as it grows without bound. - **Estimator.** The plain estimate is biased upward; the unbiased estimate drops the self-pair terms and can come out slightly **negative** when nothing moved. - **Null.** A raw MMD value has no fixed scale. A **permutation** test — shuffle the pooled rows into pseudo-reference and pseudo-live sets many times — shows what the statistic looks like with no shift. - **Cost.** It is quadratic in the number of points, so jobs subsample, typically a few thousand claims per window. In the same comparison, a multivariate test on raw, unreduced inputs did poorly; reducing dimension first helped. ## A domain classifier and its held-out AUC 1. Label reference claims 0 and live claims 1, sampling the reference down to the live window's size. 2. Split the rows in half and train any reasonably flexible classifier on one half. 3. Score the other half and compute the ROC AUC. With no shift the classifier can do no better than chance, so **AUC ≈ 0.5**; the further above 0.5, the more separable the windows. How far above 0.5 counts needs a null (a label permutation, or a binomial test on accuracy) and a cutoff, which is a threshold question. The per-row scores are the bonus: the live claims scored most live-like are **the claims that look new**, which turns an alarm into a diagnosis. Two cautions: the AUC must come from the held-out half, because training AUC is inflated by overfitting; and inputs must exclude anything that merely encodes time, such as a date or a sequential ID, or the windows separate trivially. In the image comparison the domain classifier did badly with 100 or fewer live samples and caught up with more. ## Cheaper reduced views - **The model's own outputs.** The triage model compresses each claim to three routing probabilities. Comparing their distribution between windows is cheap and label-free, and using a classifier's outputs as the reduction was the best performer overall in that comparison, though it is blind to input changes the model ignores. - **PCA reconstruction error.** Fit principal components on reference embeddings, reconstruct live embeddings from them and track the mean error. It is common practice rather than a standard with fixed constants, and it rises when correlations change even if every marginal is unchanged. | Approach | Catches joint change | Points at which claims | Cost | |---|---|---|---| | Per-dimension scores, corrected | only via marginals | no | low | | MMD with permutation null | yes | no | quadratic | | Domain classifier, held-out AUC | yes | yes | one training run | | Model output distribution | what the model reacts to | no | very low | | PCA reconstruction error | correlation changes | per-row error | low |

  • A domain classifier separating reference from live claim embeddings reaches held-out AUC 0.71 — what next?
    The windows are separable well beyond chance, so the embeddings moved jointly. Rank held-out live claims by the classifier's score and read the top ones: if they are mobile-app descriptions written differently, the shift has a nameable cause. First check the classifier is not separating on something that only encodes time, such as a date leaking into the text.
  • Why can the MMD bandwidth not be set to anything convenient?
    With a Gaussian kernel the empirical MMD shrinks toward zero both as the bandwidth goes to zero and as it grows without bound, so a badly chosen width sees almost nothing. The common default is the median pairwise distance in the pooled sample, a heuristic rather than an optimum, fixed and recorded with the reference so scores stay comparable.
  • Why watch the triage model's own output distribution as well?
    It reduces each claim to three routing probabilities, so comparing windows is cheap and needs no labels, and it focuses on shifts the model actually reacts to; one large comparison found a classifier's outputs the best reduction overall. It is blind to input changes the model ignores, so it complements an input-side check rather than replacing it.

  • If no single dimension drifted, the embedding has not drifted.
  • Testing 384 dimensions at 5% each keeps the overall false-alarm rate at 5%.
  • A domain-classifier AUC of 0.5 means the live data drifted maximally.
  • The domain classifier's training-set AUC works fine as the drift score.
  • An unbiased MMD estimate can never come out negative.
  • Any kernel bandwidth works equally well for an MMD drift check.