feat(people): confidence-aware suggestion scores (LCB) #1070
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/merge-suggestion-confidence-score"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Winner's Curse at small-N centroids. A merge suggestion (and a picker ranking) compares two estimated unit centroids: the mean of a person's face embeddings, L2-normalized. A centroid over N embeddings still carries measurement scatter ~σ/√N, so a pair of two small clusters can look far more similar than it is — the classic winner's curse of picking the minimum of many noisy estimates. Confirmed empirically: 4/4 pairs admitted by the raw 0.35 gate during 06.–07.10. were owner-rejected, all with min N ≤ 6. σ̂ = 0.139 comes from a leave-one-out residual analysis of centroid means inside large face sets (N ≥ 8, n = 2689, 2026-10), rounded up to 0.14 and used as a conservative upper bound (the residuals include genuine intra-person variance, not only measurement noise).
Formula
d— cosine distance between the two unit centroids (shared embedding space only).Z = 1.645— one-sided 95% normal quantile.σ = 0.14— leave-one-out centroid residual scatter (see Problem).n1/n2— the vector counts actually averaged into each centroid (bucket vector counts, including pending-fallback seeds) — never the SQL face count.Constants and helpers are shared by every consumer:
ASSIGNMENT_DISTANCE_SIGMA,ASSIGNMENT_DISTANCE_Z,confidenceMargin(n1, n2),lcbScore(d_pess)inClassInstanceDiscoveryService.Scope
mergeSuggestion(gate + ranking) — pessimistic distance only:d_pess > 0.35(pairs at exactly 0.35 stay in);d_pessASC →combinedFaceCountDESC →firstId;MergeSuggestionCandidate.rawDistance/.pessimisticDistance,MergeSuggestionView.score.personRanking—PersonRankingEntry.score, sorted score DESC (nulls last);n_source= candidate face embeddings in the dominant model pair,n_target= the person's shared-space embeddings.mergeTargetRankings—MergeTargetRankingEntry.score, sorted score DESC (nulls last); source side = the source instance bucket vectors.suggestSimilarInstances—InstanceSuggestionResult.score, ranked byd_pesswithn_source = 1(a single source face; pending fallback rows too); per-instance row selection still picks the raw-distance minimum (minimal change); name-fallback rows keepscore = null.User-visible behavior changes
{NN}% Scoreinstead of a bare{NN}%— merge pickers (merge-picker-similarity,merge-target-picker-similarity), the move / tentative-assign pickers (*-similarity), and the instance-suggestion labels in the media panel / edit dialog. The raw similarity moved into atitletooltip; testids unchanged.similarity = nullandscore = null, still listed, still sorted last.Tests
rtk ./gradlew :apps:api:test— BUILD SUCCESSFUL,1622 tests, 0 failures, 0 errors, 9 skippedacross 142 test classes;ClassInstanceDiscoveryServiceTest265 tests, 0 failures,DiscoveryControllerTest73 tests, 0 failures.score < similarityfor finite N, null-comparable stays null and last, andn_source = 1correctness forsuggestSimilarInstances; plus score parity betweenpersonRankingandmergeTargetRankings, and controller/record arity.svelte-check: 0 errors, 22 pre-existing warnings;vitest: 66/66 passed; Playwright:discovery-review132/132 (desktop + mobile), full suite 832 passed, 0 failed (9 flaky, all passed on retry; 23 skipped).Commits
90a3b0d7feat(people): confidence-aware merge suggestion score (LCB)dd7eb9f4feat(people): confidence-aware scoring for person ranking and assignment pickersExtend the merge-suggestion lower-confidence-bound (LCB) score to the three picker endpoints, reusing the shared ASSIGNMENT_DISTANCE_SIGMA/Z constants via new helpers confidenceMargin(n1, n2) and lcbScore(d_pess) — one formula, no duplication. - personRanking: PersonRankingEntry.score, ordered score DESC (nulls last, instance-id tiebreak); n_source = the candidate's face embeddings of the dominant model pair, n_target = the person's shared-space embeddings. - mergeTargetRankings: MergeTargetRankingEntry.score, ordered score DESC (nulls last); source side = the source instance bucket vector counts. - suggestSimilarInstances: InstanceSuggestionResult.score, ranked by the pessimistic distance with n_source = 1 (the single source face, pending fallback rows included); per-instance row selection stays on the raw distance (minimal change), name-fallback rows keep score null. No gates: the three lists stay complete — ranking and display only, so small persons stay selectable as merge targets and can grow. Web: pickers render {NN}% Score (raw similarity moved into a title tooltip), client row re-sort moves from similarity to score, and the instance-suggestion labels in the media panel / edit dialog show the score too. testids unchanged. Tests: per endpoint a small-vs-big flip (better raw similarity ranks below a better-known centroid), score < similarity for finite N, null scores stay last, n_source = 1 correctness for suggestSimilarInstances, plus score parity between personRanking and mergeTargetRankings; Playwright mocks/assertions updated to the Score chips.