faiss icon indicating copy to clipboard operation
faiss copied to clipboard

Java interface of faiss

Open zjh-nudger opened this issue 7 years ago • 26 comments

Hi, I am quite interest on faiss, a large-scale similarity search framework. However, I am not familier with C/C++. I want to know whether faiss can be packaged into Java interface(eg. JNI) for being utilized in Java application.

look forward to you reply. Best regards.

zjh-nudger avatar May 02 '17 22:05 zjh-nudger

Hi,

We have no plans for making a Java interface, but Java is supported by SWIG and we welcome pull requests for a Java interface.

mdouze avatar May 03 '17 11:05 mdouze

Thanks very much. I try to implement Java interface in few days. I will ask for your help if I encounter some problems. Thanks in advance.

zjh-nudger avatar May 03 '17 11:05 zjh-nudger

Hi,

Any updates on this one @zjh-nudger ?

claeyzre avatar Sep 08 '17 08:09 claeyzre

welcome the java interface, any updates by now @zjh-nudger .

KelvinNi avatar Nov 23 '17 02:11 KelvinNi

I started working on it, but there are some classes with multiple inheritance that need to be solved first.

ifeherva avatar Mar 03 '18 23:03 ifeherva

any updates on java implementation ?

kumarivin avatar Apr 30 '18 14:04 kumarivin

any updates on java interface?

seagullyoyo avatar May 22 '18 12:05 seagullyoyo

Have u solved it yet?

offbye avatar Jun 12 '18 11:06 offbye

@zjh-nudger @ifeherva Let me know if I can be of any help.

bvarghese1 avatar Nov 28 '18 22:11 bvarghese1

Hi,

Any updates on this one @zjh-nudger ?

batteryhp avatar Jan 02 '19 07:01 batteryhp

@mdouze

Hi, what about java jni api? Our tentative implement is about to working on the production env.

jiangshengwu avatar Mar 19 '19 13:03 jiangshengwu

++1 on Java Interface.

dexception avatar May 05 '19 09:05 dexception

Heavy plus on Java interface. It would be a wonderful bridge to have.

dkulagin avatar May 11 '19 13:05 dkulagin

Java wrapper is better than python because of better MultiThreading support in Java.

I am sure the TPS would be way way better in Java.

ashuezy avatar May 13 '19 04:05 ashuezy

To clarify the situation: there is no plan on our end to make Java wrappers for Faiss, so it would have to be a community effort.

beauby avatar May 13 '19 07:05 beauby

@beauby Can you tell me the exact swig interface file used for python so that i can start working on for java interface ?

ashuezy avatar May 13 '19 08:05 ashuezy

@ashuezy https://github.com/facebookresearch/faiss/blob/master/python/swigfaiss.swig

beauby avatar May 13 '19 08:05 beauby

Any progress on this @ashuezy ?

ssephillip avatar Jul 12 '19 16:07 ssephillip

Hey guys, we have built upon FAISS a distributed large-scale similarity search engine called Milvus, where you can use Java SDK. Check it out at https://github.com/milvus-io/milvus-sdk-java if you are interested! :wink:

youny626 avatar Oct 21 '19 04:10 youny626

a java interface, hope it help

https://github.com/gameofdimension/jni-faiss.git

gameofdimension avatar Feb 01 '20 11:02 gameofdimension

Hey guys,

I have tweaked a bit on @gameofdimension's work and created a JAR which contains src files and native .so lib. So far, it works only on Linux based systems and doesn't have support for GPU.

Project URL: https://github.com/RamanRajarathinam/JFaiss-CPU

Feedback is welcome!

raman-r-4978 avatar Sep 15 '20 06:09 raman-r-4978

I think use JavaCpp tools maybe could solve generate java api

mullerhai avatar Aug 18 '23 03:08 mullerhai

Hello, I've build a simple Faiss Java API using JavaCPP, but I've encountered an issue: the memory overhead is higher compared to C++. I think this is due to JavaCPP requires copying vectors from the Java heap to non-heap memory, resulting in duplicate vectors simultaneously occupying memory, any advice is appreciated.

https://github.com/scott01272001/faiss-java

welcome fork

scott01272001 avatar Feb 07 '24 04:02 scott01272001

Hi @scott01272001. I'll check out your repo at some point soon...but I'm wondering if you've tried 1) pass by reference and 2) BytePointer/ByteBuffer instead byte arrays. I'll move this conversation to your repo...

sourcesync avatar Feb 11 '24 01:02 sourcesync

Hi @sourcesync , thanks for your seggustion, currently I'm warpping the float array into a float pointer and passing it to the native function, is this how you mentioned "BytePointer/ByteBuffer instead of ByteArray"?

I tried using @CriticalRegion annotation on the method that needs to pass the array as parameter, It looks like the memory usage has been reduced, but as I know, using 'Get/ReleasePrimitiveArrayCritical' will freeze the GC. Are there any potential risks if I use this way?

thanks for your time

scott01272001 avatar Feb 15 '24 02:02 scott01272001

@sourcesync @scott01272001 , Any update on the Java interface for ?

ashwini-mnnit avatar Jul 25 '24 04:07 ashwini-mnnit