Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit 79ae0e3

Browse files
committed
feat: prepare for release embedding preview version
1 parent 9049862 commit 79ae0e3

File tree

11 files changed

+92
-9
lines changed

11 files changed

+92
-9
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The current version supports only one inference session on one LLama instance at
3838

3939
If you wish to have multiple inference sessions concurrently, you need to create multiple LLama instances
4040

41+
### Inference
42+
4143
```typescript
4244
import path from "path";
4345
import { LLamaClient } from "llama-node";
@@ -80,6 +82,42 @@ llama.createTextCompletion(
8082
);
8183
```
8284

85+
### Embedding
86+
87+
Preview version, embedding end token may change in the future. Do not use it in production!
88+
89+
```typescript
90+
import { LLamaClient } from "llama-node";
91+
import path from "path";
92+
93+
const model = path.resolve(process.cwd(), "./ggml-alpaca-7b-q4.bin");
94+
95+
const llama = new LLamaClient(
96+
{
97+
path: model,
98+
numCtxTokens: 128,
99+
},
100+
true
101+
);
102+
103+
const prompt = `how are you`;
104+
105+
llama
106+
.getEmbedding({
107+
prompt,
108+
numPredict: BigInt(128),
109+
temp: 0.2,
110+
topP: 1,
111+
topK: BigInt(40),
112+
repeatPenalty: 1,
113+
repeatLastN: BigInt(64),
114+
seed: BigInt(0),
115+
feedPrompt: true,
116+
})
117+
.then(console.log);
118+
119+
```
120+
83121
---
84122

85123
## Self built

example/embedding.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { LLamaClient } from "../src";
2+
import path from "path";
3+
4+
const model = path.resolve(process.cwd(), "./ggml-alpaca-7b-q4.bin");
5+
6+
const llama = new LLamaClient(
7+
{
8+
path: model,
9+
numCtxTokens: 128,
10+
},
11+
true
12+
);
13+
14+
const prompt = `how are you`;
15+
16+
llama
17+
.getEmbedding({
18+
prompt,
19+
numPredict: BigInt(128),
20+
temp: 0.2,
21+
topP: 1,
22+
topK: BigInt(40),
23+
repeatPenalty: 1,
24+
repeatLastN: BigInt(64),
25+
seed: BigInt(0),
26+
feedPrompt: true,
27+
})
28+
.then(console.log);

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "llama-node",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
77
"type": "module",
88
"scripts": {
99
"build": "tsup",
10-
"start": "tsx example/inference.ts",
10+
"start": "tsx example/embedding.ts",
1111
"test:core": "npm t --workspaces=packages/core",
1212
"start:core": "npm start --workspaces=packages/core",
1313
"build:core": "npm run build --workspaces=packages/core",
-128 Bytes
Binary file not shown.
-4.48 MB
Binary file not shown.
705 KB
Binary file not shown.
46 KB
Binary file not shown.

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@llama-node/core",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"main": "index.js",
55
"types": "index.d.ts",
66
"napi": {

packages/core/scripts/cross-compile.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ const platforms = {
44
"darwin-arm64": "aarch64-apple-darwin",
55
"darwin-x64": "x86_64-apple-darwin",
66
"linux-x64-gnu": "x86_64-unknown-linux-gnu",
7-
"win32-x64-msvc": "x86_64-pc-windows-msvc"
7+
"win32-x64-msvc": "x86_64-pc-windows-msvc",
88
};
99

1010
const compile = () => {
1111
Object.entries(platforms).forEach(([platform, target]) => {
12-
exec(`napi build --platform --target ${target} --release`).stdout?.pipe(
13-
process.stdout
12+
const buildProcess = exec(
13+
`napi build --platform --target ${target} --release`
1414
);
15+
buildProcess.stdout?.pipe(process.stdout);
16+
buildProcess.stderr?.pipe(process.stderr);
1517
});
1618
};
1719

0 commit comments

Comments
 (0)