-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathInfillExample.java
More file actions
27 lines (23 loc) · 809 Bytes
/
InfillExample.java
File metadata and controls
27 lines (23 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package examples;
import de.kherud.llama.InferenceParameters;
import de.kherud.llama.LlamaModel;
import de.kherud.llama.ModelParameters;
public class InfillExample {
public static void main(String... args) {
ModelParameters modelParams = new ModelParameters()
.setModelFilePath("models/codellama-7b.Q2_K.gguf")
.setNGpuLayers(43);
String prefix = "def remove_non_ascii(s: str) -> str:\n \"\"\" ";
String suffix = "\n return result\n";
try (LlamaModel model = new LlamaModel(modelParams)) {
System.out.print(prefix);
InferenceParameters inferParams = new InferenceParameters("")
.setInputPrefix(prefix)
.setInputSuffix(suffix);
for (LlamaModel.Output output : model.generate(inferParams)) {
System.out.print(output);
}
System.out.print(suffix);
}
}
}