Repository navigation
Description
Summary
Under "quantization": "BINARY" the graph scores a reconstruction of each vector, not the vector. findNeighborsFromVector therefore over-fetches 4 * k candidates and reranks them on the stored float vectors, which is what #8960's fix put in place. findNeighborsFromVectorGrouped never does this: it returns the graph's approximate distances unchanged. Since the only two callers of the grouped method are the groupBy branch of vector.neighbors / vectorNeighbors, adding groupBy to a BINARY query silently halves recall and changes what distance means.
Three user-visible consequences, all measured:
- recall@10 falls from 0.67 to 0.33 on the same corpus and
efSearch, withgroupSize: 1and a distinct group key per record so grouping itself removes nothing; - the
distancecolumn is the quantized-reconstruction distance, so a record queried by its own vector reports about 0.55 instead of 0.0 under EUCLIDEAN; - because
maxDistanceis a post-filter on that number, a radius query that returns the exact self-match withoutgroupByreturns nothing with it.
The file already calls this class of divergence a defect, at SQLFunctionVectorNeighbors.java:222: "Adding groupBy to a query changes how its rows are capped and nothing else about what the index can see ... Any future divergence between the two branches on what is visible is a defect, not a tradeoff of grouping."
The family
LSMVectorIndex documents exactly three search entry points and says so at LSMVectorIndex.java:7543. Each was checked:
| entry point | site | state |
|---|---|---|
findNeighborsFromVector |
7617 | clean, carries the BINARY rerank plus the #9396 widen-and-retry |
findNeighborsFromVectorApproximate |
8703 | clean, verified by running it on a BINARY index: isPQSearchAvailable() is false, so it delegates and the answer is identical, self-match at 0.0000 |
findNeighborsFromVectorGrouped / ForGroups |
8037 / 8058 | affected, both go straight to groupedSearch with no rerank |
The sparse family got this right: LSMSparseVectorIndex.topKGrouped applies rescoreExactly just as topK does, so the dense grouped path is the only asymmetric one.
Where (HEAD 2b0a7a6)
engine/src/main/java/com/arcadedb/index/vector/LSMVectorIndex.java:7617, the rerank, non-grouped only:
public List<Pair<RID, Float>> findNeighborsFromVector(final float[] queryVector, final int k, final int efSearch,
final Set<RID> allowedRIDs) {
if (metadata.quantizationType != VectorQuantizationType.BINARY || k <= 0 || queryVector == null)
return searchNeighbors(queryVector, k, efSearch, allowedRIDs);
...
reranked = rerankOnStoredVectors(queryVector, candidates, k);engine/src/main/java/com/arcadedb/index/vector/LSMVectorIndex.java:8037, the grouped twin, straight through with no quantization check at all:
public List<Pair<RID, Float>> findNeighborsFromVectorGrouped(final float[] queryVector, final int limit, final int groupSize,
final int efSearch, final Set<RID> allowedRIDs, final Function<RID, Object> groupKeyResolver) {
if (limit <= 0 || groupSize <= 0)
return Collections.emptyList();
return groupedSearch(queryVector, limit, groupSize, efSearch, allowedRIDs, groupKeyResolver, null,
Float.POSITIVE_INFINITY);
}Repro
Document type P with pid, grp, embedding ARRAY_OF_FLOATS in one bucket, 1000 random unit vectors of 32 dims, index LSM_VECTOR METADATA {"dimensions": 32, "similarity": "EUCLIDEAN", "beamWidth": 100, "quantization": "BINARY"}. 100 random queries, brute-force L2 top-10 as the oracle, efSearch 128 on both sides, groupSize: 1 with grp unique per record so the grouped answer is the plain top-10:
BINARY recall@10 flat=0.671 grouped=0.331
INT8 recall@10 flat=0.995 grouped=0.995
NONE recall@10 flat=1.000 grouped=1.000
The same matrix through inserts, updates, deletes, a post-build insert batch (delta buffer), COMPACT INDEX and a reopen is stable at roughly 0.65 flat against 0.30 grouped for BINARY at every phase, and identical flat-versus-grouped for NONE and INT8. So the gap is not grouping, the delta buffer, compaction or the reopen: it is the rerank.
At the SQL surface, 500 records, query = record 42's own embedding:
plain : pid=42 d=0.0000 pid=395 d=0.9798 pid=185 d=1.0782
grouped : pid=42 d=0.5499 pid=233 d=1.1156 pid=320 d=1.1500
plain maxDistance 0.01 : pid=42 d=0.0000
grouped maxDistance 0.01 : <empty>
Suggested fix
Rerank in the grouped path too. The cleanest shape is to have groupedSearch oversample its per-group caps by BINARY_RERANK_OVERSAMPLE when metadata.quantizationType == BINARY and run the collected candidates through rerankOnStoredVectors before GroupAdmissionState admits them, so the group caps are decided on the exact distances. That mirrors what LSMSparseVectorIndex.topKGrouped already does with rescoreExactly plus admitGroups. Admitting on approximate distances and reranking afterwards would fix the reported distance but not the recall, since the wrong members would already hold the slots.
Scope / confidence
Reproduced. Refuted three ways. That grouping itself costs recall: no, NONE and INT8 grouped match flat to four decimals on the same fixture. That the approximate PQ entry point has the same hole: no, it falls back and returns the identical reranked list. That the grouped path might be unreachable from SQL: it is reachable, and the SQL repro above shows both the wrong distance and the empty maxDistance answer. Only the two groupBy callers are affected; nothing outside BINARY quantization is.
Activity
review(#9633,#9615): retry the BINARY grouped rerank on any truncated…
review(#9633): stop widening the grouped BINARY rerank once its caps …
review(#9633,#9615): build the query vector once per grouped rerank, …
Merge pull request #9740 from ArcadeData/worktree-arcadedb-9717-9633-…
lvca commentedon Oct 11, 2026
Fixed in #9740 (release 26.11.1).
With
"quantization": "BINARY",vector.neighborswithgroupByreturned the index's approximate distances without checking them against the stored vectors, as the plain search does. Now it collects more candidates per group and more groups, re-ranks them on the exact stored vectors, and only then applieslimit,groupSizeandmaxDistance. So:distanceis the exact distance (a record queried by its own vector reports0)maxDistancequery withgroupByreturns the same matches as without itOther quantization types were not affected.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(ArcadeData#9717,ArcadeData#9633,ArcadeData#9615): LSM compaction …
fix(#9717,#9633,#9615): LSM compaction keeps the null strategy, BINAR…
review(#9633,#9615): retry the BINARY grouped rerank on any truncated…
review(#9633): stop widening the grouped BINARY rerank once its caps …
review(#9633,#9615): build the query vector once per grouped rerank, …