File tree Expand file tree Collapse file tree 7 files changed +22
-6
lines changed
src/test/java/de/kherud/llama Expand file tree Collapse file tree 7 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 3030hs_err_pid *
3131replay_pid *
3232
33+ models /* .gguf
3334src /main /cpp /de_kherud_llama_ * .h
3435src /main /resources /** /* .so
3536src /main /resources /** /* .dylib
Original file line number Diff line number Diff line change @@ -25,11 +25,12 @@ There are multiple [examples](src/test/java/examples). Make sure to set `model.h
2525``` bash
2626mvn exec:java -Dexec.mainClass=" examples.MainExample" -Dmodel.home=" /path/to/models" -Dmodel.name=" codellama-13b.Q5_K_M.gguf"
2727```
28+ Note: if your model is in the ` models ` directory, then you can ommit the ` -Dmodel.home ` property.
2829
29- You can also run some integration tests, which will automatically download a model to ` model.home ` :
30+ You can also run some integration tests, which will automatically download a model to the ` models ` directory :
3031
3132``` bash
32- mvn verify -Dmodel.home=/path/to/models
33+ mvn verify
3334```
3435
3536### No Setup required
Original file line number Diff line number Diff line change 44 set (LLAMA_METAL_DEFAULT OFF )
55endif ()
66
7+ # general
8+ option (LLAMA_NATIVE "llama: enable -march=native flag" ON )
9+
710# instruction set specific
811if (LLAMA_NATIVE)
912 set (INS_ENB OFF )
@@ -633,4 +636,4 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
633636endif ()
634637if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
635638 add_compile_definitions (_BSD_SOURCE)
636- endif ()
639+ endif ()
Original file line number Diff line number Diff line change 1+ # Local Model Directory
2+ This directory contains models which will be automatically downloaded
3+ for use in java-llama.cpp's unit tests.
Original file line number Diff line number Diff line change 4848 <junit .version>4.13.1</junit .version>
4949 <test .plugin.version>3.2.3</test .plugin.version>
5050 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
51- <integration .test.model>mistral-7b-instruct-v0.2.Q5_K_S.gguf</integration .test.model>
51+ <model .home>${project.basedir} /models</model .home>
52+ <integration .test.model>mistral-7b-instruct-v0.2.Q2_K.gguf</integration .test.model>
5253 <integration .test.model.url>https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF/resolve/main/${integration.test.model} </integration .test.model.url>
5354 </properties >
5455
110111 <systemPropertyVariables >
111112 <propertyName >model.home</propertyName >
112113 <integration .test.model>${integration.test.model} </integration .test.model>
114+ <model .home>${model.home} </model .home>
113115 </systemPropertyVariables >
114116 </configuration >
115117 <executions >
Original file line number Diff line number Diff line change @@ -86,7 +86,8 @@ public void testGenerateGrammar() {
8686 String output = sb .toString ();
8787
8888 Assert .assertTrue (output .matches ("[ab]+" ));
89- Assert .assertEquals (nPredict , model .encode (output ).length );
89+ int generated = model .encode (output ).length ;
90+ Assert .assertTrue (generated > 0 && generated <= nPredict );
9091 }
9192
9293 @ Test
@@ -126,7 +127,8 @@ public void testCompleteGrammar() {
126127 .setNPredict (nPredict );
127128 String output = model .complete ("" , params );
128129 Assert .assertTrue (output .matches ("[ab]+" ));
129- Assert .assertEquals (nPredict , model .encode (output ).length );
130+ int generated = model .encode (output ).length ;
131+ Assert .assertTrue (generated > 0 && generated <= nPredict );
130132 }
131133
132134 @ Test
Original file line number Diff line number Diff line change 11package de .kherud .llama ;
22
3+ import java .io .File ;
34import java .nio .file .Paths ;
45
56
@@ -22,6 +23,9 @@ public enum ModelResolver {
2223 public String resolve () {
2324 String ret = System .getProperty (systemPropertyName );
2425 if (ret == null ) {
26+ if (new File ("models" ).exists ()) {
27+ return "models" ;
28+ }
2529 throw new IllegalArgumentException (String .format (errorMessage , systemPropertyName ));
2630 }
2731 return ret ;
You can’t perform that action at this time.
0 commit comments