You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
content:'This is a conversation between user and assistant, a friendly chatbot.',
94
+
},
95
+
{
96
+
role:'user',
97
+
content:'Hello!',
98
+
},
99
+
],
100
+
n_predict:100,
101
+
stop: stopWords,
102
+
// ...other params
103
+
},
104
+
(data) => {
105
+
// This is a partial completion callback
106
+
const { token } = data
107
+
},
108
+
)
109
+
console.log('Result:', msgResult.text)
110
+
console.log('Timings:', msgResult.timings)
111
+
112
+
// Or do text completion
113
+
consttextResult=awaitcontext.completion(
85
114
{
86
115
prompt:'This is a conversation between user and llama, a friendly chatbot. respond in simple markdown.\n\nUser: Hello!\nLlama:',
87
116
n_predict:100,
88
-
stop: ['</s>', 'Llama:', 'User:'],
89
-
//n_threads: 4,
117
+
stop: [...stopWords, 'Llama:', 'User:'],
118
+
//...other params
90
119
},
91
120
(data) => {
92
121
// This is a partial completion callback
93
122
const { token } = data
94
123
},
95
124
)
96
-
console.log('Result:', text)
97
-
console.log('Timings:', timings)
125
+
console.log('Result:', textResult.text)
126
+
console.log('Timings:', textResult.timings)
98
127
```
99
128
100
129
The binding’s deisgn inspired by [server.cpp](https://github.com/ggerganov/llama.cpp/tree/master/examples/server) example in llama.cpp, so you can map its API to LlamaContext:
- The [Extended Virtual Addressing](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_extended-virtual-addressing) capability is recommended to enable on iOS project.
289
324
- Metal:
290
325
- We have tested to know some devices is not able to use Metal ('params.n_gpu_layers > 0') due to llama.cpp used SIMD-scoped operation, you can check if your device is supported in [Metal feature set tables](https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf), Apple7 GPU will be the minimum requirement.
291
326
- It's also not supported in iOS simulator due to [this limitation](https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator#3241609), we used constant buffers more than 14.
292
327
293
328
Android:
329
+
294
330
- Currently only supported arm64-v8a / x86_64 platform, this means you can't initialize a context on another platforms. The 64-bit platform are recommended because it can allocate more memory for the model.
0 commit comments