Make alpha loosen the diversity check for negative DOT_PRODUCT scores #860
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 595 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #860"
general
weight: 0.35
MarkWolters
Fixes #859.
The diversity check prunes candidate
cof nodepwhen an already-selected neighborshassim(c, s) > score(p, c) alpha. Alpha above 1 is meant to loosen the check so some longer edges survive. DOT_PRODUCT scores are(1 + dot) / 2, negative whendot < -1, which happens with vectors that are not unit length. For a negative score,score alphais belowscore, so every pass with alpha above 1 is stricter than the alpha = 1 pass, and alpha has no effect on those candidates. Like #714, #814, #820 and #848, this is a fix for negative DOT_PRODUCT scores; it is not a recall change for normalized data.Change
VamanaDiversityProvider.diversityThreshold(score, alpha):score >= 0 ? score alpha : score / alpha. A candidate is pruned when a selected neighbor's similarity to it is above this threshold.VamanaDiversityProvider.isDiverse(graph builder) andCompactVamanaDiversityProvider.isDiverse(compaction) both use it, computed once per candidate instead of a multiply per selected neighbor.score alpha, so EUCLIDEAN, COSINE and unit-length DOT_PRODUCT graphs do not change. When the score and the selected neighbor's similarity are both negative it is RobustPrune (Vamana, Algorithm 2) with distance-score. When the candidate's score is negative and the selected neighbor's similarity is not, the threshold stays below 0 and the candidate is pruned at every alpha, as at alpha = 1.maxDegreesurviving positive-score candidates: data in a half-space with a node opposite it (as in #813), or sparse upper layers.Tests
TestDiversityNegativeScores(new):score * alphafor scores of at least 0, -0.0 and NaN, at alpha 1.0, 1.2, 1.4 and 2.0;Full
jvector-twenty,jvector-testsandjvector-nativesuites on Ice Lake (32 cores), JDK 22: 718 tests, 0 failures (main: 713, 0 failures, same skips).Results
Ice Lake (32 cores), JDK 22, degree 32, beam 100, overflow 1.2, alpha 1.2, hierarchy, full-precision vectors.
Single-threaded 100k builds, index files compared byte for byte (main built twice is identical too):
| Dataset | Similarity | main | this PR | Edges changed |
|---|---|---|---|---|
| sift-128 | EUCLIDEAN |
a08c3c64|a08c3c64| 0 of 3.2M || cohere-english-v3 | DOT_PRODUCT (unit) |
f4629fdb|f4629fdb| 0 of 3.2M || cohere-english-v3 | COSINE |
df2316c3|df2316c3| 0 of 3.2M |cohere-english-v3-1M, DOT_PRODUCT, multithreaded builds, 4 runs each in ABBA order plus a main A/A pair:
| | main | this PR | Change | main vs main |
|---|---|---|---|---|
| Build time | 75.07 s | 74.94 s | -0.2% | 0.3% |
| Allocated per build | 29.75 GB | 29.77 GB | +0.1% | 0.9% |
| Peak heap / RSS | 8.12 / 9.36 GB | 8.11 / 9.34 GB | ~0 | |
| QPS, rerankK 10 / 40 / 100 | 84.7k / 34.8k / 17.1k | 85.1k / 35.0k / 17.2k | +0.4 / +0.8 / +0.2% | 2.1% (rerankK 10) |
| Recall@10, rerankK 10 / 100 | 0.709 / 0.958 | 0.708 / 0.958 | ~0 | 2% (rerankK 10) |
JDK 25 (one pair) shows the same. Bytecode sizes: builder
isDiverse87 -> 93, compactorisDiverse78 -> 84,diversityThreshold16; no method crosses 35 or 325.Non-unit data: Music100 (1M x 100, inner product, vector lengths 0.28-1.87), also with 1,000 added outliers (real vectors negated and scaled by 3): single-threaded builds are byte-identical to main, because every candidate there scores at least 0. The fix only changes graphs with the geometry above.
Data where it does act: 100k x 32-d vectors in three groups 120 degrees apart (length 4, spread 0.25), so every score between groups is negative, with 10k held-out queries and brute-force ground truth. Single-threaded builds differ at 367 of 100,000 nodes (350 edges removed, 524 added, of 2.0M); edges between groups go from 305 to 283. Recall@10 is unchanged: 0.9875 / 0.9963 / 0.9995 on main and 0.9876 / 0.9963 / 0.9995 here at rerankK 10 / 20 / 100.