node-llama-cpp 2.8.9 → 2.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/llama/addon.cpp +3 -2
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/gitRelease.bundle +0 -0
- package/llama/grammars/README.md +11 -1
- package/llamaBins/linux-arm64/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l/llama-addon.node +0 -0
- package/llamaBins/linux-x64/llama-addon.node +0 -0
- package/llamaBins/mac-arm64/default.metallib +0 -0
- package/llamaBins/mac-arm64/llama-addon.node +0 -0
- package/llamaBins/mac-x64/default.metallib +0 -0
- package/llamaBins/mac-x64/llama-addon.node +0 -0
- package/llamaBins/win-x64/llama-addon.exp +0 -0
- package/llamaBins/win-x64/llama-addon.lib +0 -0
- package/llamaBins/win-x64/llama-addon.node +0 -0
- package/package.json +1 -1
package/llama/addon.cpp
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "common/grammar-parser.h"
|
|
9
9
|
#include "napi.h"
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
class LLAMAModel : public Napi::ObjectWrap<LLAMAModel> {
|
|
12
13
|
public:
|
|
13
14
|
llama_model_params model_params;
|
|
@@ -167,10 +168,10 @@ class LLAMAContext : public Napi::ObjectWrap<LLAMAContext> {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
ctx = llama_new_context_with_model(model->model, context_params);
|
|
170
|
-
Napi::MemoryManagement::AdjustExternalMemory(Env(),
|
|
171
|
+
Napi::MemoryManagement::AdjustExternalMemory(Env(), llama_state_get_size(ctx));
|
|
171
172
|
}
|
|
172
173
|
~LLAMAContext() {
|
|
173
|
-
Napi::MemoryManagement::AdjustExternalMemory(Env(), -(int64_t)
|
|
174
|
+
Napi::MemoryManagement::AdjustExternalMemory(Env(), -(int64_t)llama_state_get_size(ctx));
|
|
174
175
|
llama_free(ctx);
|
|
175
176
|
model->Unref();
|
|
176
177
|
}
|
package/llama/gitRelease.bundle
CHANGED
|
Binary file
|
package/llama/grammars/README.md
CHANGED
|
@@ -51,7 +51,7 @@ single-line ::= [^\n]+ "\n"`
|
|
|
51
51
|
|
|
52
52
|
## Sequences and Alternatives
|
|
53
53
|
|
|
54
|
-
The order of symbols in a sequence
|
|
54
|
+
The order of symbols in a sequence matters. For example, in `"1. " move " " move "\n"`, the `"1. "` must come before the first `move`, etc.
|
|
55
55
|
|
|
56
56
|
Alternatives, denoted by `|`, give different sequences that are acceptable. For example, in `move ::= pawn | nonpawn | castle`, `move` can be a `pawn` move, a `nonpawn` move, or a `castle`.
|
|
57
57
|
|
|
@@ -89,3 +89,13 @@ This guide provides a brief overview. Check out the GBNF files in this directory
|
|
|
89
89
|
```
|
|
90
90
|
./main -m <model> --grammar-file grammars/some-grammar.gbnf -p 'Some prompt'
|
|
91
91
|
```
|
|
92
|
+
|
|
93
|
+
## Troubleshooting
|
|
94
|
+
|
|
95
|
+
Grammars currently have performance gotchas (see https://github.com/ggerganov/llama.cpp/issues/4218).
|
|
96
|
+
|
|
97
|
+
### Efficient optional repetitions
|
|
98
|
+
|
|
99
|
+
A common pattern is to allow repetitions of a pattern `x` up to N times.
|
|
100
|
+
|
|
101
|
+
While semantically correct, the syntax `x? x? x?.... x?` (with N repetitions) will result in extremely slow inference. Instead, you can write `(x (x (x ... (x)?...)?)?)?` (w/ N-deep nesting)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-llama-cpp",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.11",
|
|
4
4
|
"description": "Run AI models locally on your machine with node.js bindings for llama.cpp. Force a JSON schema on the model output on the generation level",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|