john-mlika opened a new pull request, #16665:
URL: https://github.com/apache/lucene/pull/16665

   
   For an asymmetric scalar-quantized encoding, an HNSW merge asks 
`Lucene104ScalarQuantizedVectorsReader#getRandomVectorScorerSupplierForMerge` 
for a merge scorer, and the reader quantizes the merged vectors again for the 
query side. It quantizes them raw, while the writer normalized the index side 
of the same segment for COSINE. With vectors that are not unit length, the 
merge fails on the quantizer's unit-vector assertion when assertions are on; 
with them off it builds the graph from query records that do not match the 
index side. The query-side corrective terms scale with the vector's norm while 
the index side does not, so the estimate leaves [-1, 1] and is clamped to 0 or 
1. On 8k 64-dim COSINE vectors with norms spread over 1 to 10, the merge 
scorer's mean absolute error against the search-time scorer is 0.21, 28% of 
pairs land on a clamp, and the merged graph's recall@10 against brute force 
over the same quantized scores drops from 0.96 to 0.71. On unit vectors the two 
scorers
  agree exactly and the fix changes nothing.
   
   Unit vectors, the other similarities, and the symmetric encodings are 
unaffected, which is why the format tests never saw it: 
`BaseKnnVectorsFormatTestCase` feeds normalized vectors. 
`Lucene102BinaryQuantizedVectorsReader` normalizes at the same spot. The same 
code is on `branch_10x` and in 10.5.1.
   
   The fix normalizes the query side for COSINE with the same 
`NormalizedFloatVectorValues` the writer uses, moved into its own 
package-private file so the reader does not depend on the writer. The test 
indexes non-unit COSINE vectors on each asymmetric encoding, force-merges with 
a graph threshold of 0 so the merge scorer is always requested, and checks that 
the merge scorer scores a pair exactly like the search-time scorer does for the 
same vector. It fails on main in both assertion modes and passes with the fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to