@kelceyp/caw-server 1.0.194 → 1.0.195
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/dist/embedding-worker.js +16 -1
- package/dist/main.js +358 -358
- package/package.json +1 -1
package/dist/embedding-worker.js
CHANGED
|
@@ -40,7 +40,14 @@ const run = async () => {
|
|
|
40
40
|
|
|
41
41
|
// Log download progress to stderr (visible in parent process output)
|
|
42
42
|
pipe = await pipeline('feature-extraction', MODEL_NAME, {
|
|
43
|
-
|
|
43
|
+
dtype: 'q8',
|
|
44
|
+
device: 'cpu',
|
|
45
|
+
session_options: {
|
|
46
|
+
enableCpuMemArena: false,
|
|
47
|
+
enableMemPattern: false,
|
|
48
|
+
intraOpNumThreads: 1,
|
|
49
|
+
interOpNumThreads: 1,
|
|
50
|
+
},
|
|
44
51
|
progress_callback: (progress) => {
|
|
45
52
|
if (progress.status === 'download') {
|
|
46
53
|
process.stderr.write(`[EmbeddingWorker] Downloading: ${progress.file} (${Math.round((progress.loaded / progress.total) * 100)}%)\n`);
|
|
@@ -51,6 +58,10 @@ const run = async () => {
|
|
|
51
58
|
}
|
|
52
59
|
});
|
|
53
60
|
|
|
61
|
+
// Log loaded model details and baseline memory
|
|
62
|
+
const rss = Math.round(process.memoryUsage().rss / 1024 / 1024);
|
|
63
|
+
process.stderr.write(`[EmbeddingWorker] Model loaded. RSS: ${rss}MB\n`);
|
|
64
|
+
|
|
54
65
|
sendLine({ ready: true });
|
|
55
66
|
} catch (err) {
|
|
56
67
|
sendLine({ error: `Pipeline load failed: ${err.message}` });
|
|
@@ -59,6 +70,7 @@ const run = async () => {
|
|
|
59
70
|
|
|
60
71
|
// Process requests from parent line by line
|
|
61
72
|
const rl = createInterface({ input: process.stdin });
|
|
73
|
+
let embedCallCount = 0;
|
|
62
74
|
|
|
63
75
|
rl.on('line', async (line) => {
|
|
64
76
|
let req;
|
|
@@ -86,6 +98,9 @@ const run = async () => {
|
|
|
86
98
|
vectors.push(Array.from(output.data.slice(start, end)));
|
|
87
99
|
}
|
|
88
100
|
output.dispose();
|
|
101
|
+
embedCallCount++;
|
|
102
|
+
const embedRss = Math.round(process.memoryUsage().rss / 1024 / 1024);
|
|
103
|
+
process.stderr.write(`[EmbeddingWorker] Embed #${embedCallCount}: ${texts.length} texts, RSS: ${embedRss}MB\n`);
|
|
89
104
|
sendLine({ vectors });
|
|
90
105
|
} catch (err) {
|
|
91
106
|
sendLine({ error: `Embedding failed: ${err.message}` });
|