kherud / java-llama.cpp

Java Bindings for llama.cpp - A Port of Facebook's LLaMA model in C/C++
MIT License
279 stars 28 forks source link

java.lang.NoSuchFieldError: de.kherud.llama.InferenceParameters.antiPrompt [Ljava/lang/String; #31

Closed enimatek-nl closed 5 months ago

enimatek-nl commented 9 months ago

Just like the issues #26 #30 #27 I had this issue on a Linux machine (amd64). From the failed pipeline on github I added the artifacts that were build with success and changed the path paramter. But this will result in the following error:

java.lang.NoSuchFieldError: de.kherud.llama.InferenceParameters.antiPrompt [Ljava/lang/String;
    at jdk.internal.loader.NativeLibraries.load (Native Method)
    at jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open (NativeLibraries.java:331)
    at jdk.internal.loader.NativeLibraries.loadLibrary (NativeLibraries.java:197)
    at jdk.internal.loader.NativeLibraries.loadLibrary (NativeLibraries.java:139)
    at java.lang.ClassLoader.loadLibrary (ClassLoader.java:2418)
    at java.lang.Runtime.load0 (Runtime.java:852)
    at java.lang.System.load (System.java:2021)
    at de.kherud.llama.LlamaLoader.loadNativeLibrary (LlamaLoader.java:162)
    at de.kherud.llama.LlamaLoader.loadNativeLibrary (LlamaLoader.java:106)
    at de.kherud.llama.LlamaLoader.initialize (LlamaLoader.java:66)
    at de.kherud.llama.LlamaModel.<clinit> (LlamaModel.java:29)
    at nl.enimatek.llama.chat.Main.main (Main.java:16)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:283)
    at java.lang.Thread.run (Thread.java:1583)

I also 'rebuild' the whole project including the llama-ccp on my M2 macbook where the current Maven-jar -does- work, but rebuilding it gives the same result as the above.

So I think, even after getting the pipeline to publish the updated llama libraries (that is now causing all the above mentioned open issues), the JNI will break anyways, maybe because of an update in the llama-ccp? - I'm not proficient in c++/jni enough atm, and the reason for me to use this library ;)

peerkoel commented 8 months ago

This probably has to do with a difference in "antiprompt" in the jni definition and "antiPrompt" with capital P in the Java class definition. I had the same issue when using the library as a maven dependency. Using the code from the repo in my project works for me, together with building the shared library.

kherud commented 5 months ago

I just released version 3.0 and this should be fixed. Note, that the naming changed to InferenceParameters#setStopStrings(String[]).