-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathtest_isolated.dart
53 lines (42 loc) · 1.29 KB
/
test_isolated.dart
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ignore_for_file: avoid_print
import 'dart:io';
import 'package:llama_cpp_dart/llama_cpp_dart.dart';
void main() async {
Llama.libraryPath = "bin/MAC_ARM64/libllama.dylib";
ContextParams contextParams = ContextParams();
contextParams.nPredict = 500;
contextParams.nCtx = 8192;
contextParams.nBatch = 8192;
final samplerParams = SamplerParams();
samplerParams.temp = 1.0;
samplerParams.topK = 64;
samplerParams.topP = 0.95;
samplerParams.penaltyRepeat = 1.1;
String modelPath = "/Users/adel/Workspace/gguf/gemma-3-12b-it-Q4_K_M.gguf";
final loadCommand = LlamaLoad(
path: modelPath,
modelParams: ModelParams(),
contextParams: contextParams,
samplingParams: samplerParams,
// format: ChatMLFormat(),
);
final llamaParent = LlamaParent(loadCommand);
await llamaParent.init();
int i = 0;
List<String> prompts = [
"<start_of_turn>What is 2 * 4?<end_of_turn>\n<start_of_turn>model\n",
"<start_of_turn>What is 4 * 4?<end_of_turn>\n<start_of_turn>model\n"
];
llamaParent.stream.listen((response) {
stdout.write(response);
});
llamaParent.completions.listen((event) {
i++;
if (i >= prompts.length) {
llamaParent.dispose();
} else {
llamaParent.sendPrompt(prompts[i]);
}
});
llamaParent.sendPrompt(prompts[0]);
}