@remit/search-service 0.0.16 → 0.0.18
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/package.json +2 -2
- package/src/embeddings.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/search-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"better-sqlite3": "^12.11.1",
|
|
41
41
|
"p-limit": "^6.2.0",
|
|
42
42
|
"sqlite-vec": "^0.1.9",
|
|
43
|
-
"zod": "
|
|
43
|
+
"zod": "^3.25.0",
|
|
44
44
|
"@aws-sdk/client-bedrock-runtime": "*",
|
|
45
45
|
"@aws-sdk/client-s3vectors": "*",
|
|
46
46
|
"@smithy/types": "^4.16.1",
|
package/src/embeddings.ts
CHANGED
|
@@ -164,6 +164,15 @@ export class LocalEmbeddingService implements EmbeddingService {
|
|
|
164
164
|
try {
|
|
165
165
|
return await pipeline("feature-extraction", this.modelId, {
|
|
166
166
|
dtype: this.dtype,
|
|
167
|
+
// onnxruntime's CPU arena is a high-water mark: it sizes itself to the
|
|
168
|
+
// largest batch the session has ever run and never returns that memory
|
|
169
|
+
// to the OS. On a shared 4 GB box that makes one wide batch permanent
|
|
170
|
+
// resident memory, so the search-index worker's throttle (#585) could
|
|
171
|
+
// only ever stop the growth, never walk it back. Off, allocations go
|
|
172
|
+
// through the ordinary allocator and freed tensors are actually
|
|
173
|
+
// released; the cost is per-inference malloc traffic, which is noise
|
|
174
|
+
// next to the model's own work.
|
|
175
|
+
session_options: { enableCpuMemArena: false },
|
|
167
176
|
});
|
|
168
177
|
} catch (error) {
|
|
169
178
|
throw new EmbeddingModelUnavailableError(this.modelId, { cause: error });
|
|
@@ -177,7 +186,17 @@ export class LocalEmbeddingService implements EmbeddingService {
|
|
|
177
186
|
pooling: "mean",
|
|
178
187
|
normalize: true,
|
|
179
188
|
});
|
|
180
|
-
|
|
189
|
+
try {
|
|
190
|
+
return tensor.tolist() as number[][];
|
|
191
|
+
} finally {
|
|
192
|
+
// The pooled, normalized output — one vector per text, not the
|
|
193
|
+
// per-token hidden states, which the pipeline drops itself. Small per
|
|
194
|
+
// call, and its buffer is a native allocation outside the V8 heap
|
|
195
|
+
// (#585), so it is released here rather than whenever GC gets to a JS
|
|
196
|
+
// wrapper that looks cheap. `tolist` has already copied what the caller
|
|
197
|
+
// needs. The arena setting above is what bounds the large allocations.
|
|
198
|
+
tensor.dispose();
|
|
199
|
+
}
|
|
181
200
|
};
|
|
182
201
|
}
|
|
183
202
|
|