iprithv commented on code in PR #16065:
URL: https://github.com/apache/lucene/pull/16065#discussion_r3253274061
##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/codecs/faiss/FaissLibraryNativeImpl.java:
##########
@@ -275,31 +268,34 @@ private interface FloatToFloatFunction {
private final Arena arena;
private final MemorySegment indexPointer;
private final FloatToFloatFunction scaler;
+ private final VectorSimilarityFunction function;
+ private final int dimension;
private boolean closed;
- private Index(MemorySegment indexPointer) {
+ private Index(MemorySegment indexPointer, VectorSimilarityFunction
function) {
this.arena = Arena.ofShared();
this.indexPointer =
indexPointer
// Ensure timely cleanup
.reinterpret(arena, wrapper::faiss_Index_free);
-
- // Get underlying function
- int metricType = wrapper.faiss_Index_metric_type(indexPointer);
- VectorSimilarityFunction function = metricToFunction(metricType);
Review Comment:
sure, I’ve removed faiss_Index_metric_type and on the mismatch, we should be
fine now since we’re not inferring anything from faiss and added a comment in
both indexing and query paths calling out the normalization cost.
for perf, I ran now knnGraphTester (same as knnPerfTest) on ~10k cohere
vectors
| format | metric | latency | qps | recall |
|--------|--------------|---------|-----|--------|
| flat | dot_product | 146 ms | 684 | 1.000 |
| flat | cosine | 163 ms | 613 | 0.999 |
| hnsw | dot_product | 137 ms | 729 | 1.000 |
| hnsw | cosine | 154 ms | 649 | 0.999 |
so cosine is ~10–15% slower than dot product, due to normalization. Thanks!
--
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]