mr-memory 2.18.3 → 2.18.4
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 +1 -1
- package/upload.ts +6 -3
package/package.json
CHANGED
package/upload.ts
CHANGED
|
@@ -143,7 +143,8 @@ type MemoryLine = {
|
|
|
143
143
|
const MAX_ITEM_CHARS = 8000;
|
|
144
144
|
const TARGET_CHUNK_CHARS = 4000;
|
|
145
145
|
const MAX_BATCH_BYTES = 2_000_000;
|
|
146
|
-
const
|
|
146
|
+
const MAX_BATCH_COUNT_DEFAULT = 100;
|
|
147
|
+
const MAX_BATCH_COUNT_QWEN = 25;
|
|
147
148
|
const BATCH_SLEEP_MS = 150;
|
|
148
149
|
const MAX_HTTP_RETRIES = 3;
|
|
149
150
|
|
|
@@ -430,14 +431,16 @@ export async function runUpload(params: {
|
|
|
430
431
|
return;
|
|
431
432
|
}
|
|
432
433
|
|
|
433
|
-
// Batch
|
|
434
|
+
// Batch — smaller batches for Qwen (4096-dim vectors are 4x heavier)
|
|
435
|
+
const isQwen = embeddings && ['qwen', 'qwen3', 'qwen3-8b', 'qwen3-embedding', 'qwen3-embedding-8b'].includes(embeddings.toLowerCase());
|
|
436
|
+
const maxBatchCount = isQwen ? MAX_BATCH_COUNT_QWEN : MAX_BATCH_COUNT_DEFAULT;
|
|
434
437
|
const batches: MemoryLine[][] = [];
|
|
435
438
|
let currentBatch: MemoryLine[] = [];
|
|
436
439
|
let currentBytes = 0;
|
|
437
440
|
|
|
438
441
|
for (const line of allLines) {
|
|
439
442
|
const lineBytes = JSON.stringify(line).length + 1;
|
|
440
|
-
if (currentBytes + lineBytes > MAX_BATCH_BYTES || currentBatch.length >=
|
|
443
|
+
if (currentBytes + lineBytes > MAX_BATCH_BYTES || currentBatch.length >= maxBatchCount) {
|
|
441
444
|
if (currentBatch.length > 0) batches.push(currentBatch);
|
|
442
445
|
currentBatch = [line];
|
|
443
446
|
currentBytes = lineBytes;
|