@bendyline/gezel-knowledge 1.2.11 → 1.2.12
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/browser.d.ts +77 -0
- package/dist/browser.js +1410 -0
- package/dist/index.d.ts +16 -330
- package/dist/index.js +66 -19
- package/dist/registry-xi2R42Av.d.ts +372 -0
- package/package.json +6 -2
package/dist/browser.js
ADDED
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
// src/chunking/markdown-chunker.ts
|
|
2
|
+
var HEADING = /^(#{1,6})\s+(.*)$/;
|
|
3
|
+
function chunkMarkdownProfile(md, opts) {
|
|
4
|
+
const lines = md.split(/\r?\n/);
|
|
5
|
+
const headIdx = [];
|
|
6
|
+
for (let i = 0; i < lines.length; i++) {
|
|
7
|
+
if (HEADING.test(lines[i])) headIdx.push(i);
|
|
8
|
+
}
|
|
9
|
+
const out = [];
|
|
10
|
+
if (headIdx.length === 0) {
|
|
11
|
+
return chunkRange(lines, 0, lines.length - 1, "doc", [], opts);
|
|
12
|
+
}
|
|
13
|
+
if (headIdx[0] > 0) {
|
|
14
|
+
out.push(...chunkRange(lines, 0, headIdx[0] - 1, "preamble", [], opts));
|
|
15
|
+
}
|
|
16
|
+
const stack = [];
|
|
17
|
+
for (let h = 0; h < headIdx.length; h++) {
|
|
18
|
+
const start = headIdx[h];
|
|
19
|
+
const end = h + 1 < headIdx.length ? headIdx[h + 1] - 1 : lines.length - 1;
|
|
20
|
+
const m = HEADING.exec(lines[start]);
|
|
21
|
+
const depth = m ? m[1]?.length ?? 1 : 1;
|
|
22
|
+
const text = m ? (m[2] ?? "").trim() : "";
|
|
23
|
+
while (stack.length > 0 && stack[stack.length - 1].depth >= depth) {
|
|
24
|
+
stack.pop();
|
|
25
|
+
}
|
|
26
|
+
stack.push({ depth, text });
|
|
27
|
+
const headingPath = stack.map((s) => s.text).filter((t) => t.length > 0);
|
|
28
|
+
out.push(...chunkRange(lines, start, end, "section", headingPath, opts));
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function measure(text, opts) {
|
|
33
|
+
return opts.unit === "chars" ? text.length : opts.countTokens(text);
|
|
34
|
+
}
|
|
35
|
+
function chunkRange(lines, start, end, kind, headingPath, opts) {
|
|
36
|
+
const out = [];
|
|
37
|
+
const lineSize = /* @__PURE__ */ new Map();
|
|
38
|
+
const sizeOf = (i) => {
|
|
39
|
+
let s = lineSize.get(i);
|
|
40
|
+
if (s === void 0) {
|
|
41
|
+
s = measure(lines[i] ?? "", opts);
|
|
42
|
+
lineSize.set(i, s);
|
|
43
|
+
}
|
|
44
|
+
return s;
|
|
45
|
+
};
|
|
46
|
+
const joinCost = opts.unit === "chars" ? 1 : 0;
|
|
47
|
+
let cursor = start;
|
|
48
|
+
while (cursor <= end) {
|
|
49
|
+
const first = lines[cursor] ?? "";
|
|
50
|
+
if (sizeOf(cursor) > opts.target) {
|
|
51
|
+
for (const text2 of splitOversizeLine(first, opts)) {
|
|
52
|
+
if (text2) out.push({ kind, lineStart: cursor + 1, lineEnd: cursor + 1, text: text2, headingPath });
|
|
53
|
+
}
|
|
54
|
+
cursor++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
let chunkEnd = cursor;
|
|
58
|
+
let size = sizeOf(cursor);
|
|
59
|
+
while (chunkEnd + 1 <= end) {
|
|
60
|
+
const nextSize = sizeOf(chunkEnd + 1) + joinCost;
|
|
61
|
+
if (size + nextSize > opts.target) break;
|
|
62
|
+
size += nextSize;
|
|
63
|
+
chunkEnd++;
|
|
64
|
+
}
|
|
65
|
+
const text = lines.slice(cursor, chunkEnd + 1).join("\n").trim();
|
|
66
|
+
if (text) {
|
|
67
|
+
out.push({ kind, lineStart: cursor + 1, lineEnd: chunkEnd + 1, text, headingPath });
|
|
68
|
+
}
|
|
69
|
+
if (chunkEnd >= end) break;
|
|
70
|
+
let nextCursor = chunkEnd + 1;
|
|
71
|
+
let overlap = 0;
|
|
72
|
+
for (let i = chunkEnd; i > cursor; i--) {
|
|
73
|
+
const length = sizeOf(i) + joinCost;
|
|
74
|
+
if (overlap + length > opts.overlap) break;
|
|
75
|
+
overlap += length;
|
|
76
|
+
nextCursor = i;
|
|
77
|
+
}
|
|
78
|
+
cursor = Math.max(cursor + 1, nextCursor);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function splitOversizeLine(line, opts) {
|
|
83
|
+
if (opts.unit === "chars") {
|
|
84
|
+
const out2 = [];
|
|
85
|
+
let offset = 0;
|
|
86
|
+
while (offset < line.length) {
|
|
87
|
+
out2.push(line.slice(offset, offset + opts.target).trim());
|
|
88
|
+
if (offset + opts.target >= line.length) break;
|
|
89
|
+
offset += opts.target - opts.overlap;
|
|
90
|
+
}
|
|
91
|
+
return out2;
|
|
92
|
+
}
|
|
93
|
+
const sentences = line.split(/(?<=[.!?])\s+/);
|
|
94
|
+
const out = [];
|
|
95
|
+
let current = [];
|
|
96
|
+
let currentTokens = 0;
|
|
97
|
+
const flush = () => {
|
|
98
|
+
if (current.length > 0) {
|
|
99
|
+
const text = current.join(" ").trim();
|
|
100
|
+
if (text) out.push(text);
|
|
101
|
+
current = [];
|
|
102
|
+
currentTokens = 0;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
for (const sentence of sentences) {
|
|
106
|
+
const tokens = opts.countTokens(sentence);
|
|
107
|
+
if (tokens > opts.target) {
|
|
108
|
+
flush();
|
|
109
|
+
const charsPerToken = Math.max(1, sentence.length / tokens);
|
|
110
|
+
const window = Math.max(1, Math.floor(opts.target * charsPerToken));
|
|
111
|
+
const step = Math.max(1, window - Math.floor(opts.overlap * charsPerToken));
|
|
112
|
+
for (let offset = 0; offset < sentence.length; offset += step) {
|
|
113
|
+
const piece = sentence.slice(offset, offset + window).trim();
|
|
114
|
+
if (piece) out.push(piece);
|
|
115
|
+
if (offset + window >= sentence.length) break;
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (currentTokens + tokens > opts.target) flush();
|
|
120
|
+
current.push(sentence);
|
|
121
|
+
currentTokens += tokens;
|
|
122
|
+
}
|
|
123
|
+
flush();
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/chunking/embed-input.ts
|
|
128
|
+
function buildContextHeader(title, headingPath, maxTokens, countTokens) {
|
|
129
|
+
const path = headingPath.filter((h) => h !== title);
|
|
130
|
+
let header = path.length > 0 ? `${title}
|
|
131
|
+
${path.join(" > ")}
|
|
132
|
+
` : `${title}
|
|
133
|
+
`;
|
|
134
|
+
if (countTokens(header) > maxTokens) {
|
|
135
|
+
header = `${title}
|
|
136
|
+
`;
|
|
137
|
+
if (countTokens(header) > maxTokens) header = "";
|
|
138
|
+
}
|
|
139
|
+
return header;
|
|
140
|
+
}
|
|
141
|
+
function passageEmbedInput(input) {
|
|
142
|
+
return `${input.passageInstruction}${buildContextHeader(
|
|
143
|
+
input.title,
|
|
144
|
+
input.headingPath,
|
|
145
|
+
input.headerMaxTokens,
|
|
146
|
+
input.countTokens
|
|
147
|
+
)}${input.text}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/profiles/vector-floors.ts
|
|
151
|
+
var KNOWLEDGE_VECTOR_FLOORS = {
|
|
152
|
+
// Handboek 1.1.2: answers ≥ 0.687, off-topic ≤ 0.624.
|
|
153
|
+
"bendyline/handboek": 0.65,
|
|
154
|
+
// The project index's measured floor for the daemon's own embedder
|
|
155
|
+
// (index-store VECTOR_ARM_MIN_SIMILARITY) — what a folder-built catalog gets.
|
|
156
|
+
"bge-small-en-v1.5@1": 0.55,
|
|
157
|
+
// Wikipedia Food & Drink 2026.4.3: answers ≥ 0.869; the scale is compressed
|
|
158
|
+
// and 2 of 25 off-topic prompts still reach it, so grounding and the
|
|
159
|
+
// relevance model do the rest.
|
|
160
|
+
"multilingual-e5-small@2": 0.865,
|
|
161
|
+
// Revision 1 has the same model, instructions and int8 vectors — only its
|
|
162
|
+
// stage-1 sign bits differ — so its rerank cosine is on the same scale.
|
|
163
|
+
"multilingual-e5-small@1": 0.865,
|
|
164
|
+
// Handboek 1.2.2 + a Food & Drink sample re-embedded in this profile (the
|
|
165
|
+
// labelled calibration queries): answers ≥ 0.762 in both, off-topic ≤ 0.706,
|
|
166
|
+
// a query's best chunk in the OTHER catalog ≤ 0.715. A wide gap; the scale
|
|
167
|
+
// is far less compressed than e5's.
|
|
168
|
+
"embeddinggemma-2-512@1": 0.735,
|
|
169
|
+
// Media rows of the same profile, workspace and catalogs alike
|
|
170
|
+
// (evals/src/retrieval-bench/MEDIA-BENCH-2026-10-07.md). Each sits a step
|
|
171
|
+
// above the lowest floor no off-topic prompt reached on the bench corpus,
|
|
172
|
+
// because a real library is larger and its off-topic maximum higher.
|
|
173
|
+
// COCO photos: no off-topic hit from 0.66; 293 of 300 answers keep their photo.
|
|
174
|
+
"embeddinggemma-2-512@1#image": 0.67,
|
|
175
|
+
// MSR-VTT clips: no off-topic hit from 0.65; 54 of 60 answers clear 0.65 and 0.66.
|
|
176
|
+
"embeddinggemma-2-512@1#video": 0.66,
|
|
177
|
+
// ESC-50 sounds: scores bunch (a wrong clip clears 0.66 for most queries),
|
|
178
|
+
// so the floor does less here than ranking; 47 of 50 answers clear 0.68.
|
|
179
|
+
"embeddinggemma-2-512@1#audio": 0.68
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/reader/bit-scan.ts
|
|
183
|
+
var POPCOUNT8 = new Uint8Array(256);
|
|
184
|
+
for (let i = 1; i < 256; i++) POPCOUNT8[i] = (i & 1) + POPCOUNT8[i >> 1];
|
|
185
|
+
function asymmetricTopK(index, query, k, eligibleChunkIds, excludedChunkIds) {
|
|
186
|
+
const { bits, bytesPerRow, rows } = index;
|
|
187
|
+
if (Math.ceil(query.length / 8) !== bytesPerRow) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`query has ${query.length} dimensions, shard rows have ${bytesPerRow} bytes of bits`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const limit = Math.min(k, eligibleChunkIds?.size ?? rows);
|
|
193
|
+
if (limit <= 0) return [];
|
|
194
|
+
const lut = new Float32Array(bytesPerRow * 256);
|
|
195
|
+
for (let p = 0; p < bytesPerRow; p++) {
|
|
196
|
+
for (let b = 0; b < 256; b++) {
|
|
197
|
+
let s = 0;
|
|
198
|
+
for (let i = 0; i < 8; i++) {
|
|
199
|
+
const d = p * 8 + i;
|
|
200
|
+
if (d >= query.length) break;
|
|
201
|
+
const v = query[d];
|
|
202
|
+
s += b >> i & 1 ? v : -v;
|
|
203
|
+
}
|
|
204
|
+
lut[p * 256 + b] = s;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const heapScore = new Float64Array(limit);
|
|
208
|
+
const heapId = new Int32Array(limit);
|
|
209
|
+
let size = 0;
|
|
210
|
+
const worse = (i, j) => heapScore[i] < heapScore[j] || heapScore[i] === heapScore[j] && heapId[i] > heapId[j];
|
|
211
|
+
const swap = (i, j) => {
|
|
212
|
+
const s = heapScore[i];
|
|
213
|
+
const id = heapId[i];
|
|
214
|
+
heapScore[i] = heapScore[j];
|
|
215
|
+
heapId[i] = heapId[j];
|
|
216
|
+
heapScore[j] = s;
|
|
217
|
+
heapId[j] = id;
|
|
218
|
+
};
|
|
219
|
+
const siftUp = (start) => {
|
|
220
|
+
let i = start;
|
|
221
|
+
while (i > 0) {
|
|
222
|
+
const parent = i - 1 >> 1;
|
|
223
|
+
if (!worse(i, parent)) break;
|
|
224
|
+
swap(i, parent);
|
|
225
|
+
i = parent;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const siftDown = (start) => {
|
|
229
|
+
let i = start;
|
|
230
|
+
for (; ; ) {
|
|
231
|
+
const left = 2 * i + 1;
|
|
232
|
+
if (left >= size) break;
|
|
233
|
+
const right = left + 1;
|
|
234
|
+
const child = right < size && worse(right, left) ? right : left;
|
|
235
|
+
if (!worse(child, i)) break;
|
|
236
|
+
swap(child, i);
|
|
237
|
+
i = child;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
let offset = 0;
|
|
241
|
+
for (let r = 0; r < rows; r++) {
|
|
242
|
+
if (eligibleChunkIds && !eligibleChunkIds.has(r + 1) || excludedChunkIds?.has(r + 1)) {
|
|
243
|
+
offset += bytesPerRow;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
let score = 0;
|
|
247
|
+
for (let p = 0; p < bytesPerRow; p++) {
|
|
248
|
+
score += lut[p * 256 + bits[offset + p]];
|
|
249
|
+
}
|
|
250
|
+
offset += bytesPerRow;
|
|
251
|
+
if (size < limit) {
|
|
252
|
+
heapScore[size] = score;
|
|
253
|
+
heapId[size] = r + 1;
|
|
254
|
+
size++;
|
|
255
|
+
siftUp(size - 1);
|
|
256
|
+
} else if (score > heapScore[0] || score === heapScore[0] && r + 1 < heapId[0]) {
|
|
257
|
+
heapScore[0] = score;
|
|
258
|
+
heapId[0] = r + 1;
|
|
259
|
+
siftDown(0);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const hits = [];
|
|
263
|
+
for (let i = 0; i < size; i++) {
|
|
264
|
+
hits.push({ chunkId: heapId[i], score: heapScore[i] });
|
|
265
|
+
}
|
|
266
|
+
hits.sort((a, b) => b.score - a.score || a.chunkId - b.chunkId);
|
|
267
|
+
return hits;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/profiles/e5-small-center.ts
|
|
271
|
+
var MULTILINGUAL_E5_SMALL_CENTER = [
|
|
272
|
+
0.046697,
|
|
273
|
+
-0.013211,
|
|
274
|
+
-0.042276,
|
|
275
|
+
-0.049082,
|
|
276
|
+
0.060627,
|
|
277
|
+
-0.032643,
|
|
278
|
+
0.029874,
|
|
279
|
+
0.033307,
|
|
280
|
+
0.058447,
|
|
281
|
+
-0.012016,
|
|
282
|
+
0.046472,
|
|
283
|
+
5991e-6,
|
|
284
|
+
0.04884,
|
|
285
|
+
-0.028836,
|
|
286
|
+
-0.03244,
|
|
287
|
+
0.045633,
|
|
288
|
+
0.056798,
|
|
289
|
+
-0.043557,
|
|
290
|
+
-0.034472,
|
|
291
|
+
-0.05355,
|
|
292
|
+
0.026363,
|
|
293
|
+
-0.010318,
|
|
294
|
+
-0.030487,
|
|
295
|
+
0.047083,
|
|
296
|
+
0.057205,
|
|
297
|
+
0.035654,
|
|
298
|
+
-0.017461,
|
|
299
|
+
0.010881,
|
|
300
|
+
0.047985,
|
|
301
|
+
-0.048514,
|
|
302
|
+
-0.048956,
|
|
303
|
+
-0.027643,
|
|
304
|
+
0.053259,
|
|
305
|
+
-0.051057,
|
|
306
|
+
0.045055,
|
|
307
|
+
0.017888,
|
|
308
|
+
-0.055755,
|
|
309
|
+
-0.046578,
|
|
310
|
+
0.05214,
|
|
311
|
+
-0.037085,
|
|
312
|
+
-0.016268,
|
|
313
|
+
0.027508,
|
|
314
|
+
0.035793,
|
|
315
|
+
0.052082,
|
|
316
|
+
0.034885,
|
|
317
|
+
0.047174,
|
|
318
|
+
-0.036778,
|
|
319
|
+
0.031394,
|
|
320
|
+
-9156e-6,
|
|
321
|
+
-0.02486,
|
|
322
|
+
-0.048897,
|
|
323
|
+
0.052576,
|
|
324
|
+
0.017289,
|
|
325
|
+
0.047794,
|
|
326
|
+
0.051939,
|
|
327
|
+
-0.051261,
|
|
328
|
+
-0.061345,
|
|
329
|
+
-0.056267,
|
|
330
|
+
-0.049305,
|
|
331
|
+
0.047241,
|
|
332
|
+
0.043763,
|
|
333
|
+
-0.04506,
|
|
334
|
+
0.015752,
|
|
335
|
+
0.017543,
|
|
336
|
+
0.067856,
|
|
337
|
+
0.065763,
|
|
338
|
+
0.037218,
|
|
339
|
+
0.044877,
|
|
340
|
+
-0.057149,
|
|
341
|
+
-0.028072,
|
|
342
|
+
-0.060566,
|
|
343
|
+
0.064004,
|
|
344
|
+
6095e-6,
|
|
345
|
+
-0.039693,
|
|
346
|
+
0.021968,
|
|
347
|
+
0.02654,
|
|
348
|
+
0.025546,
|
|
349
|
+
-0.048954,
|
|
350
|
+
0.026967,
|
|
351
|
+
-0.045002,
|
|
352
|
+
-0.055556,
|
|
353
|
+
-0.034963,
|
|
354
|
+
-0.03466,
|
|
355
|
+
0.032486,
|
|
356
|
+
-0.049597,
|
|
357
|
+
0.058718,
|
|
358
|
+
0.048021,
|
|
359
|
+
-0.066783,
|
|
360
|
+
0.059049,
|
|
361
|
+
-0.04665,
|
|
362
|
+
0.052902,
|
|
363
|
+
0.031438,
|
|
364
|
+
-0.061515,
|
|
365
|
+
-0.05342,
|
|
366
|
+
-0.068253,
|
|
367
|
+
-0.06666,
|
|
368
|
+
-0.04553,
|
|
369
|
+
0.059252,
|
|
370
|
+
0.050728,
|
|
371
|
+
-0.030429,
|
|
372
|
+
0.067182,
|
|
373
|
+
-0.038819,
|
|
374
|
+
0.049358,
|
|
375
|
+
-0.055247,
|
|
376
|
+
-0.032933,
|
|
377
|
+
0.041239,
|
|
378
|
+
0.035164,
|
|
379
|
+
-0.066574,
|
|
380
|
+
0.05348,
|
|
381
|
+
-0.052658,
|
|
382
|
+
-0.034758,
|
|
383
|
+
0.037219,
|
|
384
|
+
0.064111,
|
|
385
|
+
0.047861,
|
|
386
|
+
-0.04608,
|
|
387
|
+
-0.041338,
|
|
388
|
+
-0.016072,
|
|
389
|
+
-0.046026,
|
|
390
|
+
0.0255,
|
|
391
|
+
-0.041581,
|
|
392
|
+
0.059684,
|
|
393
|
+
-0.019611,
|
|
394
|
+
-0.050363,
|
|
395
|
+
-0.061268,
|
|
396
|
+
-0.057556,
|
|
397
|
+
-0.03184,
|
|
398
|
+
0.018522,
|
|
399
|
+
0.046887,
|
|
400
|
+
0.054774,
|
|
401
|
+
0.012536,
|
|
402
|
+
0.033019,
|
|
403
|
+
0.033211,
|
|
404
|
+
0.029609,
|
|
405
|
+
0.050215,
|
|
406
|
+
0.035425,
|
|
407
|
+
0.076419,
|
|
408
|
+
-0.055196,
|
|
409
|
+
-0.010016,
|
|
410
|
+
-936e-6,
|
|
411
|
+
-0.023764,
|
|
412
|
+
-0.059648,
|
|
413
|
+
0.054857,
|
|
414
|
+
-0.030456,
|
|
415
|
+
0.041281,
|
|
416
|
+
0.063894,
|
|
417
|
+
0.035466,
|
|
418
|
+
0.069754,
|
|
419
|
+
-0.026593,
|
|
420
|
+
0.066305,
|
|
421
|
+
-0.028609,
|
|
422
|
+
0.05324,
|
|
423
|
+
-0.022879,
|
|
424
|
+
0.04882,
|
|
425
|
+
0.032385,
|
|
426
|
+
0.042921,
|
|
427
|
+
-0.043319,
|
|
428
|
+
-0.065022,
|
|
429
|
+
-0.044018,
|
|
430
|
+
0.04237,
|
|
431
|
+
0.051018,
|
|
432
|
+
-0.048907,
|
|
433
|
+
-0.053045,
|
|
434
|
+
-0.057301,
|
|
435
|
+
-0.019731,
|
|
436
|
+
-0.060812,
|
|
437
|
+
-0.043114,
|
|
438
|
+
0.021207,
|
|
439
|
+
0.052498,
|
|
440
|
+
-0.038307,
|
|
441
|
+
-0.037082,
|
|
442
|
+
-0.043732,
|
|
443
|
+
0.045959,
|
|
444
|
+
-0.044296,
|
|
445
|
+
0.057199,
|
|
446
|
+
-0.011835,
|
|
447
|
+
0.054221,
|
|
448
|
+
-0.046354,
|
|
449
|
+
0.043442,
|
|
450
|
+
0.063337,
|
|
451
|
+
0.041964,
|
|
452
|
+
-0.032836,
|
|
453
|
+
-0.020089,
|
|
454
|
+
-0.056327,
|
|
455
|
+
-0.05089,
|
|
456
|
+
-0.053933,
|
|
457
|
+
-0.035486,
|
|
458
|
+
-0.046215,
|
|
459
|
+
0.025754,
|
|
460
|
+
0.032986,
|
|
461
|
+
-0.025048,
|
|
462
|
+
-9903e-6,
|
|
463
|
+
0.031162,
|
|
464
|
+
-0.050969,
|
|
465
|
+
-0.049401,
|
|
466
|
+
-0.046206,
|
|
467
|
+
0.023197,
|
|
468
|
+
-0.033441,
|
|
469
|
+
0.045075,
|
|
470
|
+
0.043318,
|
|
471
|
+
0.043766,
|
|
472
|
+
-6601e-6,
|
|
473
|
+
-0.023077,
|
|
474
|
+
0.033917,
|
|
475
|
+
0.032279,
|
|
476
|
+
0.034874,
|
|
477
|
+
5185e-6,
|
|
478
|
+
-0.057329,
|
|
479
|
+
0.048437,
|
|
480
|
+
-0.033964,
|
|
481
|
+
0.044195,
|
|
482
|
+
0.051107,
|
|
483
|
+
-0.056642,
|
|
484
|
+
-0.070856,
|
|
485
|
+
0.045431,
|
|
486
|
+
-0.047205,
|
|
487
|
+
-0.021457,
|
|
488
|
+
3103e-6,
|
|
489
|
+
0.062536,
|
|
490
|
+
-0.037804,
|
|
491
|
+
0.031278,
|
|
492
|
+
0.041619,
|
|
493
|
+
-0.015547,
|
|
494
|
+
0.052298,
|
|
495
|
+
-0.078327,
|
|
496
|
+
-0.052303,
|
|
497
|
+
0.043099,
|
|
498
|
+
0.05375,
|
|
499
|
+
-0.041854,
|
|
500
|
+
-0.038314,
|
|
501
|
+
0.039399,
|
|
502
|
+
-0.047769,
|
|
503
|
+
-0.038469,
|
|
504
|
+
-0.056793,
|
|
505
|
+
-0.064312,
|
|
506
|
+
-0.047884,
|
|
507
|
+
-0.060067,
|
|
508
|
+
-0.030687,
|
|
509
|
+
0.030053,
|
|
510
|
+
0.033569,
|
|
511
|
+
-0.038014,
|
|
512
|
+
-0.032396,
|
|
513
|
+
-0.041395,
|
|
514
|
+
0.038163,
|
|
515
|
+
-0.056206,
|
|
516
|
+
0.047115,
|
|
517
|
+
-0.038099,
|
|
518
|
+
-0.031927,
|
|
519
|
+
0.033857,
|
|
520
|
+
-0.011227,
|
|
521
|
+
0.032883,
|
|
522
|
+
0.032516,
|
|
523
|
+
-0.045622,
|
|
524
|
+
-0.044387,
|
|
525
|
+
-0.034374,
|
|
526
|
+
-0.030433,
|
|
527
|
+
0.055097,
|
|
528
|
+
0.055568,
|
|
529
|
+
0.058726,
|
|
530
|
+
-0.043569,
|
|
531
|
+
0.031854,
|
|
532
|
+
775e-5,
|
|
533
|
+
-0.022533,
|
|
534
|
+
0.096133,
|
|
535
|
+
0.052876,
|
|
536
|
+
0.045582,
|
|
537
|
+
0.041868,
|
|
538
|
+
-0.039268,
|
|
539
|
+
-0.037865,
|
|
540
|
+
-0.054658,
|
|
541
|
+
-0.031297,
|
|
542
|
+
-0.058104,
|
|
543
|
+
0.018705,
|
|
544
|
+
0.031934,
|
|
545
|
+
-0.052746,
|
|
546
|
+
-0.044438,
|
|
547
|
+
-0.029991,
|
|
548
|
+
0.011917,
|
|
549
|
+
0.070103,
|
|
550
|
+
-0.046682,
|
|
551
|
+
-0.048965,
|
|
552
|
+
0.046255,
|
|
553
|
+
0.027877,
|
|
554
|
+
0.0475,
|
|
555
|
+
0.044287,
|
|
556
|
+
0.04251,
|
|
557
|
+
-0.017647,
|
|
558
|
+
-0.017812,
|
|
559
|
+
0.055672,
|
|
560
|
+
-0.042207,
|
|
561
|
+
-0.035516,
|
|
562
|
+
-0.025558,
|
|
563
|
+
-0.062443,
|
|
564
|
+
0.037519,
|
|
565
|
+
-0.031697,
|
|
566
|
+
0.064998,
|
|
567
|
+
0.045949,
|
|
568
|
+
302e-6,
|
|
569
|
+
0.065205,
|
|
570
|
+
-0.052016,
|
|
571
|
+
0.036721,
|
|
572
|
+
-0.034769,
|
|
573
|
+
-0.049074,
|
|
574
|
+
0.040413,
|
|
575
|
+
0.045425,
|
|
576
|
+
-0.068063,
|
|
577
|
+
0.021485,
|
|
578
|
+
8549e-6,
|
|
579
|
+
0.028179,
|
|
580
|
+
0.026914,
|
|
581
|
+
0.020493,
|
|
582
|
+
0.056155,
|
|
583
|
+
0.047202,
|
|
584
|
+
-0.049085,
|
|
585
|
+
-0.022624,
|
|
586
|
+
0.063734,
|
|
587
|
+
0.05471,
|
|
588
|
+
-0.032258,
|
|
589
|
+
0.047761,
|
|
590
|
+
-0.065033,
|
|
591
|
+
-0.047818,
|
|
592
|
+
-0.034254,
|
|
593
|
+
-0.062863,
|
|
594
|
+
-0.01362,
|
|
595
|
+
-0.053904,
|
|
596
|
+
0.024415,
|
|
597
|
+
0.044367,
|
|
598
|
+
-0.064056,
|
|
599
|
+
-0.038419,
|
|
600
|
+
0.038997,
|
|
601
|
+
1015e-6,
|
|
602
|
+
0.038928,
|
|
603
|
+
-0.045794,
|
|
604
|
+
-0.038313,
|
|
605
|
+
0.043922,
|
|
606
|
+
-0.05873,
|
|
607
|
+
-0.020314,
|
|
608
|
+
-0.020457,
|
|
609
|
+
0.045522,
|
|
610
|
+
-0.057731,
|
|
611
|
+
-0.062966,
|
|
612
|
+
0.023159,
|
|
613
|
+
0.020283,
|
|
614
|
+
-0.057352,
|
|
615
|
+
0.044701,
|
|
616
|
+
-0.03585,
|
|
617
|
+
-0.052798,
|
|
618
|
+
0.056931,
|
|
619
|
+
-0.035609,
|
|
620
|
+
-0.035113,
|
|
621
|
+
0.026919,
|
|
622
|
+
0.059404,
|
|
623
|
+
-0.084434,
|
|
624
|
+
0.014558,
|
|
625
|
+
0.06226,
|
|
626
|
+
-0.044173,
|
|
627
|
+
0.044172,
|
|
628
|
+
-0.046482,
|
|
629
|
+
-0.034933,
|
|
630
|
+
0.052513,
|
|
631
|
+
0.044018,
|
|
632
|
+
-0.057677,
|
|
633
|
+
-0.033961,
|
|
634
|
+
0.046334,
|
|
635
|
+
0.065767,
|
|
636
|
+
0.044779,
|
|
637
|
+
0.063658,
|
|
638
|
+
-0.022574,
|
|
639
|
+
-4821e-6,
|
|
640
|
+
0.037388,
|
|
641
|
+
-0.043197,
|
|
642
|
+
0.063,
|
|
643
|
+
0.048943,
|
|
644
|
+
-0.049495,
|
|
645
|
+
0.014798,
|
|
646
|
+
-0.018176,
|
|
647
|
+
-0.03824,
|
|
648
|
+
-0.045486,
|
|
649
|
+
0.053828,
|
|
650
|
+
-0.056118,
|
|
651
|
+
-0.067025,
|
|
652
|
+
0.027818,
|
|
653
|
+
0.050305,
|
|
654
|
+
0.037134,
|
|
655
|
+
0.049673
|
|
656
|
+
];
|
|
657
|
+
|
|
658
|
+
// src/profiles/embeddinggemma-2-center.ts
|
|
659
|
+
var EMBEDDINGGEMMA_2_512_CENTER = [
|
|
660
|
+
-3987e-6,
|
|
661
|
+
0.017212,
|
|
662
|
+
0.023034,
|
|
663
|
+
-0.020831,
|
|
664
|
+
0.013136,
|
|
665
|
+
0.018836,
|
|
666
|
+
7334e-6,
|
|
667
|
+
-0.022294,
|
|
668
|
+
5809e-6,
|
|
669
|
+
-0.147176,
|
|
670
|
+
-5646e-6,
|
|
671
|
+
-0.022884,
|
|
672
|
+
-0.011497,
|
|
673
|
+
1292e-6,
|
|
674
|
+
0.014257,
|
|
675
|
+
-1878e-6,
|
|
676
|
+
0.051834,
|
|
677
|
+
-0.012991,
|
|
678
|
+
933e-6,
|
|
679
|
+
0.022558,
|
|
680
|
+
-0.034902,
|
|
681
|
+
-0.030019,
|
|
682
|
+
0.017879,
|
|
683
|
+
0.015619,
|
|
684
|
+
-0.014837,
|
|
685
|
+
0.028657,
|
|
686
|
+
0.017575,
|
|
687
|
+
-0.045617,
|
|
688
|
+
-0.03244,
|
|
689
|
+
0.23277,
|
|
690
|
+
-0.021971,
|
|
691
|
+
-0.026583,
|
|
692
|
+
0.011485,
|
|
693
|
+
-0.01468,
|
|
694
|
+
0.044649,
|
|
695
|
+
0.018019,
|
|
696
|
+
-0.011519,
|
|
697
|
+
0.035574,
|
|
698
|
+
512e-5,
|
|
699
|
+
-0.030136,
|
|
700
|
+
4583e-6,
|
|
701
|
+
0.018314,
|
|
702
|
+
-0.028859,
|
|
703
|
+
0.027199,
|
|
704
|
+
0.020695,
|
|
705
|
+
-849e-6,
|
|
706
|
+
0.015867,
|
|
707
|
+
-0.024724,
|
|
708
|
+
-8979e-6,
|
|
709
|
+
0.023625,
|
|
710
|
+
0.028948,
|
|
711
|
+
-0.025744,
|
|
712
|
+
-1547e-6,
|
|
713
|
+
0.0281,
|
|
714
|
+
0.024258,
|
|
715
|
+
0.02262,
|
|
716
|
+
1386e-6,
|
|
717
|
+
0.015002,
|
|
718
|
+
3764e-6,
|
|
719
|
+
0.016978,
|
|
720
|
+
0.019178,
|
|
721
|
+
0.012229,
|
|
722
|
+
-193e-6,
|
|
723
|
+
0.032654,
|
|
724
|
+
-0.030602,
|
|
725
|
+
-1749e-6,
|
|
726
|
+
0.027403,
|
|
727
|
+
-4047e-6,
|
|
728
|
+
0.031605,
|
|
729
|
+
0.023884,
|
|
730
|
+
0.015804,
|
|
731
|
+
3971e-6,
|
|
732
|
+
0.021826,
|
|
733
|
+
0.02457,
|
|
734
|
+
-0.023111,
|
|
735
|
+
-0.032593,
|
|
736
|
+
-0.090226,
|
|
737
|
+
0.020798,
|
|
738
|
+
6402e-6,
|
|
739
|
+
0.015607,
|
|
740
|
+
-8457e-6,
|
|
741
|
+
-0.010067,
|
|
742
|
+
6362e-6,
|
|
743
|
+
9973e-6,
|
|
744
|
+
0.0122,
|
|
745
|
+
-0.020958,
|
|
746
|
+
-0.031666,
|
|
747
|
+
0.034654,
|
|
748
|
+
-0.012847,
|
|
749
|
+
-1119e-6,
|
|
750
|
+
0.024259,
|
|
751
|
+
0.018097,
|
|
752
|
+
9105e-6,
|
|
753
|
+
-9523e-6,
|
|
754
|
+
-0.022682,
|
|
755
|
+
-5167e-6,
|
|
756
|
+
-0.022959,
|
|
757
|
+
0.012175,
|
|
758
|
+
-0.020933,
|
|
759
|
+
0.014024,
|
|
760
|
+
-4898e-6,
|
|
761
|
+
-2018e-6,
|
|
762
|
+
-7178e-6,
|
|
763
|
+
0.038098,
|
|
764
|
+
0.016307,
|
|
765
|
+
5668e-6,
|
|
766
|
+
-0.014475,
|
|
767
|
+
661e-6,
|
|
768
|
+
-1287e-6,
|
|
769
|
+
-0.025024,
|
|
770
|
+
5704e-6,
|
|
771
|
+
-0.32188,
|
|
772
|
+
-0.026611,
|
|
773
|
+
0.032111,
|
|
774
|
+
-9511e-6,
|
|
775
|
+
0.260031,
|
|
776
|
+
0.027274,
|
|
777
|
+
-909e-5,
|
|
778
|
+
0.055461,
|
|
779
|
+
0.024395,
|
|
780
|
+
-0.017894,
|
|
781
|
+
0.061775,
|
|
782
|
+
-8529e-6,
|
|
783
|
+
-1795e-6,
|
|
784
|
+
-0.017545,
|
|
785
|
+
0.011492,
|
|
786
|
+
0.044594,
|
|
787
|
+
38e-4,
|
|
788
|
+
-0.02231,
|
|
789
|
+
0.029977,
|
|
790
|
+
0.010629,
|
|
791
|
+
-489e-5,
|
|
792
|
+
2646e-6,
|
|
793
|
+
6408e-6,
|
|
794
|
+
-0.014453,
|
|
795
|
+
-0.020764,
|
|
796
|
+
-0.018043,
|
|
797
|
+
-0.015625,
|
|
798
|
+
0.074213,
|
|
799
|
+
-0.012319,
|
|
800
|
+
-8038e-6,
|
|
801
|
+
-6265e-6,
|
|
802
|
+
0.012548,
|
|
803
|
+
-621e-6,
|
|
804
|
+
-0.021893,
|
|
805
|
+
0.039889,
|
|
806
|
+
3623e-6,
|
|
807
|
+
-0.029173,
|
|
808
|
+
-716e-6,
|
|
809
|
+
-0.013168,
|
|
810
|
+
-6674e-6,
|
|
811
|
+
-0.010069,
|
|
812
|
+
-0.02451,
|
|
813
|
+
0.015114,
|
|
814
|
+
-0.012945,
|
|
815
|
+
1561e-6,
|
|
816
|
+
0.013299,
|
|
817
|
+
-0.029098,
|
|
818
|
+
0.01304,
|
|
819
|
+
0.013519,
|
|
820
|
+
-0.014282,
|
|
821
|
+
0.026849,
|
|
822
|
+
-2462e-6,
|
|
823
|
+
0.019473,
|
|
824
|
+
-8227e-6,
|
|
825
|
+
-822e-6,
|
|
826
|
+
-7241e-6,
|
|
827
|
+
4259e-6,
|
|
828
|
+
-0.016026,
|
|
829
|
+
7987e-6,
|
|
830
|
+
-7065e-6,
|
|
831
|
+
-1229e-6,
|
|
832
|
+
-0.01583,
|
|
833
|
+
0.021277,
|
|
834
|
+
0.013837,
|
|
835
|
+
0.024282,
|
|
836
|
+
-7589e-6,
|
|
837
|
+
-0.016577,
|
|
838
|
+
7774e-6,
|
|
839
|
+
0.010479,
|
|
840
|
+
-0.012539,
|
|
841
|
+
-0.020799,
|
|
842
|
+
0.026506,
|
|
843
|
+
8733e-6,
|
|
844
|
+
-0.015001,
|
|
845
|
+
2151e-6,
|
|
846
|
+
-0.011922,
|
|
847
|
+
-0.02785,
|
|
848
|
+
-0.060631,
|
|
849
|
+
3372e-6,
|
|
850
|
+
0.022441,
|
|
851
|
+
-0.012448,
|
|
852
|
+
6827e-6,
|
|
853
|
+
-7047e-6,
|
|
854
|
+
1249e-6,
|
|
855
|
+
-2934e-6,
|
|
856
|
+
4559e-6,
|
|
857
|
+
-0.011409,
|
|
858
|
+
-0.012564,
|
|
859
|
+
5788e-6,
|
|
860
|
+
-0.020554,
|
|
861
|
+
-4292e-6,
|
|
862
|
+
0.01927,
|
|
863
|
+
0.013487,
|
|
864
|
+
-0.015484,
|
|
865
|
+
9704e-6,
|
|
866
|
+
5617e-6,
|
|
867
|
+
0.02447,
|
|
868
|
+
2056e-6,
|
|
869
|
+
0.011381,
|
|
870
|
+
0.039831,
|
|
871
|
+
-7878e-6,
|
|
872
|
+
-0.011366,
|
|
873
|
+
-814e-5,
|
|
874
|
+
8099e-6,
|
|
875
|
+
6637e-6,
|
|
876
|
+
154e-6,
|
|
877
|
+
0.072273,
|
|
878
|
+
7195e-6,
|
|
879
|
+
-0.011899,
|
|
880
|
+
0.016669,
|
|
881
|
+
3331e-6,
|
|
882
|
+
0.032787,
|
|
883
|
+
-0.012251,
|
|
884
|
+
-6049e-6,
|
|
885
|
+
-0.017814,
|
|
886
|
+
0.055136,
|
|
887
|
+
0.028157,
|
|
888
|
+
-0.028898,
|
|
889
|
+
0.035646,
|
|
890
|
+
0.036174,
|
|
891
|
+
-5621e-6,
|
|
892
|
+
0.050018,
|
|
893
|
+
-0.040307,
|
|
894
|
+
0.060677,
|
|
895
|
+
58e-6,
|
|
896
|
+
-0.045134,
|
|
897
|
+
4752e-6,
|
|
898
|
+
7161e-6,
|
|
899
|
+
0.040398,
|
|
900
|
+
-0.051202,
|
|
901
|
+
-572e-6,
|
|
902
|
+
6186e-6,
|
|
903
|
+
-0.010613,
|
|
904
|
+
0.039894,
|
|
905
|
+
-0.014924,
|
|
906
|
+
49e-4,
|
|
907
|
+
-0.011771,
|
|
908
|
+
9397e-6,
|
|
909
|
+
9457e-6,
|
|
910
|
+
0.025576,
|
|
911
|
+
2251e-6,
|
|
912
|
+
0.020638,
|
|
913
|
+
-0.029722,
|
|
914
|
+
7545e-6,
|
|
915
|
+
-533e-6,
|
|
916
|
+
0.026445,
|
|
917
|
+
921e-6,
|
|
918
|
+
9681e-6,
|
|
919
|
+
-959e-6,
|
|
920
|
+
-0.018021,
|
|
921
|
+
807e-5,
|
|
922
|
+
8041e-6,
|
|
923
|
+
-8004e-6,
|
|
924
|
+
4422e-6,
|
|
925
|
+
-2478e-6,
|
|
926
|
+
7376e-6,
|
|
927
|
+
-828e-5,
|
|
928
|
+
8006e-6,
|
|
929
|
+
-3182e-6,
|
|
930
|
+
5771e-6,
|
|
931
|
+
-526e-5,
|
|
932
|
+
0.01422,
|
|
933
|
+
-3677e-6,
|
|
934
|
+
-0.010823,
|
|
935
|
+
0.019873,
|
|
936
|
+
3328e-6,
|
|
937
|
+
4427e-6,
|
|
938
|
+
0.02227,
|
|
939
|
+
-0.014147,
|
|
940
|
+
0.014306,
|
|
941
|
+
-5089e-6,
|
|
942
|
+
-0.010849,
|
|
943
|
+
322e-5,
|
|
944
|
+
-8249e-6,
|
|
945
|
+
0.019141,
|
|
946
|
+
-0.012199,
|
|
947
|
+
0.015451,
|
|
948
|
+
0.026615,
|
|
949
|
+
0.02352,
|
|
950
|
+
0.011117,
|
|
951
|
+
-399e-6,
|
|
952
|
+
0.016821,
|
|
953
|
+
0.023447,
|
|
954
|
+
6638e-6,
|
|
955
|
+
8598e-6,
|
|
956
|
+
-0.02239,
|
|
957
|
+
0.017325,
|
|
958
|
+
0.022729,
|
|
959
|
+
9922e-6,
|
|
960
|
+
-4099e-6,
|
|
961
|
+
9124e-6,
|
|
962
|
+
-8221e-6,
|
|
963
|
+
-7554e-6,
|
|
964
|
+
0.046752,
|
|
965
|
+
0.027253,
|
|
966
|
+
437e-6,
|
|
967
|
+
4693e-6,
|
|
968
|
+
7093e-6,
|
|
969
|
+
-0.014217,
|
|
970
|
+
-0.024195,
|
|
971
|
+
2768e-6,
|
|
972
|
+
-0.012022,
|
|
973
|
+
-0.012142,
|
|
974
|
+
-4326e-6,
|
|
975
|
+
-0.01054,
|
|
976
|
+
0.01168,
|
|
977
|
+
4821e-6,
|
|
978
|
+
-5609e-6,
|
|
979
|
+
-0.096205,
|
|
980
|
+
-0.018675,
|
|
981
|
+
-0.017776,
|
|
982
|
+
-0.010107,
|
|
983
|
+
-0.012825,
|
|
984
|
+
-644e-6,
|
|
985
|
+
0.011283,
|
|
986
|
+
3759e-6,
|
|
987
|
+
-0.025286,
|
|
988
|
+
2306e-6,
|
|
989
|
+
9735e-6,
|
|
990
|
+
-158e-5,
|
|
991
|
+
0.012131,
|
|
992
|
+
-0.018451,
|
|
993
|
+
0.014135,
|
|
994
|
+
6421e-6,
|
|
995
|
+
-7006e-6,
|
|
996
|
+
-6122e-6,
|
|
997
|
+
0.013727,
|
|
998
|
+
8605e-6,
|
|
999
|
+
-6385e-6,
|
|
1000
|
+
-0.016703,
|
|
1001
|
+
-0.184351,
|
|
1002
|
+
4162e-6,
|
|
1003
|
+
0.022412,
|
|
1004
|
+
-0.021583,
|
|
1005
|
+
-5397e-6,
|
|
1006
|
+
-0.011593,
|
|
1007
|
+
-1118e-6,
|
|
1008
|
+
0.013629,
|
|
1009
|
+
4367e-6,
|
|
1010
|
+
238e-5,
|
|
1011
|
+
0.030207,
|
|
1012
|
+
2765e-6,
|
|
1013
|
+
0.015452,
|
|
1014
|
+
-0.023998,
|
|
1015
|
+
0.016889,
|
|
1016
|
+
5828e-6,
|
|
1017
|
+
0.01799,
|
|
1018
|
+
-0.019521,
|
|
1019
|
+
0.012821,
|
|
1020
|
+
-0.021567,
|
|
1021
|
+
5999e-6,
|
|
1022
|
+
0.017122,
|
|
1023
|
+
-9796e-6,
|
|
1024
|
+
6654e-6,
|
|
1025
|
+
291e-5,
|
|
1026
|
+
-0.017359,
|
|
1027
|
+
9342e-6,
|
|
1028
|
+
-929e-6,
|
|
1029
|
+
-0.012544,
|
|
1030
|
+
-8234e-6,
|
|
1031
|
+
0.016922,
|
|
1032
|
+
0.018215,
|
|
1033
|
+
-758e-6,
|
|
1034
|
+
5614e-6,
|
|
1035
|
+
0.02137,
|
|
1036
|
+
7615e-6,
|
|
1037
|
+
0.010542,
|
|
1038
|
+
635e-6,
|
|
1039
|
+
0.023702,
|
|
1040
|
+
0.020834,
|
|
1041
|
+
0.013032,
|
|
1042
|
+
0.011873,
|
|
1043
|
+
-2792e-6,
|
|
1044
|
+
0.04144,
|
|
1045
|
+
-0.02252,
|
|
1046
|
+
0.027235,
|
|
1047
|
+
-0.012274,
|
|
1048
|
+
-4002e-6,
|
|
1049
|
+
0.022356,
|
|
1050
|
+
-0.020197,
|
|
1051
|
+
0.270597,
|
|
1052
|
+
-3966e-6,
|
|
1053
|
+
-4187e-6,
|
|
1054
|
+
-0.014922,
|
|
1055
|
+
-0.013515,
|
|
1056
|
+
-0.01073,
|
|
1057
|
+
5186e-6,
|
|
1058
|
+
-0.01013,
|
|
1059
|
+
-0.024027,
|
|
1060
|
+
-897e-6,
|
|
1061
|
+
0.023069,
|
|
1062
|
+
0.021741,
|
|
1063
|
+
573e-6,
|
|
1064
|
+
-7467e-6,
|
|
1065
|
+
823e-5,
|
|
1066
|
+
0.037651,
|
|
1067
|
+
-0.017797,
|
|
1068
|
+
-0.014499,
|
|
1069
|
+
2699e-6,
|
|
1070
|
+
-0.010982,
|
|
1071
|
+
-0.027587,
|
|
1072
|
+
0.028585,
|
|
1073
|
+
-6217e-6,
|
|
1074
|
+
-9743e-6,
|
|
1075
|
+
7437e-6,
|
|
1076
|
+
-0.023614,
|
|
1077
|
+
-0.023206,
|
|
1078
|
+
-0.029976,
|
|
1079
|
+
-903e-6,
|
|
1080
|
+
-5667e-6,
|
|
1081
|
+
-0.011557,
|
|
1082
|
+
0.011335,
|
|
1083
|
+
-0.019149,
|
|
1084
|
+
0.027405,
|
|
1085
|
+
-0.032284,
|
|
1086
|
+
-0.010479,
|
|
1087
|
+
-0.013504,
|
|
1088
|
+
0.013693,
|
|
1089
|
+
-6407e-6,
|
|
1090
|
+
8791e-6,
|
|
1091
|
+
-4461e-6,
|
|
1092
|
+
-2256e-6,
|
|
1093
|
+
-0.015897,
|
|
1094
|
+
8837e-6,
|
|
1095
|
+
-1417e-6,
|
|
1096
|
+
0.02557,
|
|
1097
|
+
-0.012118,
|
|
1098
|
+
-0.021653,
|
|
1099
|
+
3051e-6,
|
|
1100
|
+
-4168e-6,
|
|
1101
|
+
-0.01862,
|
|
1102
|
+
-9461e-6,
|
|
1103
|
+
-0.01088,
|
|
1104
|
+
-982e-5,
|
|
1105
|
+
-0.011997,
|
|
1106
|
+
-0.015663,
|
|
1107
|
+
-0.021258,
|
|
1108
|
+
5679e-6,
|
|
1109
|
+
0.012566,
|
|
1110
|
+
1521e-6,
|
|
1111
|
+
-8604e-6,
|
|
1112
|
+
0.012445,
|
|
1113
|
+
8421e-6,
|
|
1114
|
+
-0.033856,
|
|
1115
|
+
-0.019957,
|
|
1116
|
+
146e-6,
|
|
1117
|
+
-185e-6,
|
|
1118
|
+
781e-6,
|
|
1119
|
+
0.018164,
|
|
1120
|
+
4102e-6,
|
|
1121
|
+
-0.022985,
|
|
1122
|
+
-8788e-6,
|
|
1123
|
+
-4097e-6,
|
|
1124
|
+
0.02217,
|
|
1125
|
+
-0.019959,
|
|
1126
|
+
-0.011669,
|
|
1127
|
+
5313e-6,
|
|
1128
|
+
381e-6,
|
|
1129
|
+
3747e-6,
|
|
1130
|
+
-0.036681,
|
|
1131
|
+
-6177e-6,
|
|
1132
|
+
-0.014834,
|
|
1133
|
+
-0.031706,
|
|
1134
|
+
0.010642,
|
|
1135
|
+
1258e-6,
|
|
1136
|
+
0.01296,
|
|
1137
|
+
0.016435,
|
|
1138
|
+
-8722e-6,
|
|
1139
|
+
-0.010652,
|
|
1140
|
+
9787e-6,
|
|
1141
|
+
-474e-5,
|
|
1142
|
+
0.011086,
|
|
1143
|
+
-0.020615,
|
|
1144
|
+
0.021049,
|
|
1145
|
+
-468e-5,
|
|
1146
|
+
8645e-6,
|
|
1147
|
+
-9937e-6,
|
|
1148
|
+
216e-5,
|
|
1149
|
+
0.010686,
|
|
1150
|
+
-6216e-6,
|
|
1151
|
+
-0.011397,
|
|
1152
|
+
-5593e-6,
|
|
1153
|
+
9687e-6,
|
|
1154
|
+
0.017522,
|
|
1155
|
+
-6329e-6,
|
|
1156
|
+
9519e-6,
|
|
1157
|
+
-0.022554,
|
|
1158
|
+
-0.02169,
|
|
1159
|
+
3307e-6,
|
|
1160
|
+
-4782e-6,
|
|
1161
|
+
1506e-6,
|
|
1162
|
+
1607e-6,
|
|
1163
|
+
-3791e-6,
|
|
1164
|
+
-3601e-6,
|
|
1165
|
+
0.030061,
|
|
1166
|
+
-468e-5,
|
|
1167
|
+
-0.186431,
|
|
1168
|
+
-1492e-6,
|
|
1169
|
+
0.02242,
|
|
1170
|
+
-8878e-6,
|
|
1171
|
+
0.01108
|
|
1172
|
+
];
|
|
1173
|
+
|
|
1174
|
+
// src/profiles/registry.ts
|
|
1175
|
+
var SHARED_ENCODING = {
|
|
1176
|
+
pooling: "mean",
|
|
1177
|
+
normalized: true,
|
|
1178
|
+
dimensions: 384,
|
|
1179
|
+
maxTokens: 512,
|
|
1180
|
+
vectorEncoding: "bit+int8",
|
|
1181
|
+
distance: { stage1: "hamming", stage2: "cosine" },
|
|
1182
|
+
quantization: {
|
|
1183
|
+
int8: { method: "symmetric-linear", scale: 127 },
|
|
1184
|
+
binary: { method: "sign", threshold: 0, packing: "lsb-first" }
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
var MULTILINGUAL_E5_SMALL_1 = {
|
|
1188
|
+
id: "multilingual-e5-small@1",
|
|
1189
|
+
model: {
|
|
1190
|
+
repo: "Xenova/multilingual-e5-small",
|
|
1191
|
+
revision: "761b726dd34fb83930e26aab4e9ac3899aa1fa78",
|
|
1192
|
+
onnxFile: "onnx/model.onnx",
|
|
1193
|
+
onnxDigest: "sha256:4aa845c27760e06e9a686b9d8b5d440eae4b6612cd09e5b522b716d3941f77ff"
|
|
1194
|
+
},
|
|
1195
|
+
tokenizer: {
|
|
1196
|
+
kind: "sentencepiece-xlmr",
|
|
1197
|
+
file: "tokenizer.json",
|
|
1198
|
+
digest: "sha256:0b44a9d7b51c3c62626640cda0e2c2f70fdacdc25bbbd68038369d14ebdf4c39"
|
|
1199
|
+
},
|
|
1200
|
+
queryInstruction: "query: ",
|
|
1201
|
+
passageInstruction: "passage: ",
|
|
1202
|
+
...SHARED_ENCODING
|
|
1203
|
+
};
|
|
1204
|
+
var MULTILINGUAL_E5_SMALL_2 = {
|
|
1205
|
+
...MULTILINGUAL_E5_SMALL_1,
|
|
1206
|
+
id: "multilingual-e5-small@2",
|
|
1207
|
+
quantization: {
|
|
1208
|
+
int8: { method: "symmetric-linear", scale: 127 },
|
|
1209
|
+
binary: {
|
|
1210
|
+
method: "centered-sign",
|
|
1211
|
+
threshold: 0,
|
|
1212
|
+
packing: "lsb-first",
|
|
1213
|
+
center: [...MULTILINGUAL_E5_SMALL_CENTER]
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
var BGE_SMALL_EN_V15_1 = {
|
|
1218
|
+
id: "bge-small-en-v1.5@1",
|
|
1219
|
+
model: {
|
|
1220
|
+
repo: "Xenova/bge-small-en-v1.5",
|
|
1221
|
+
revision: "ea104dacec62c0de699686887e3f920caeb4f3e3",
|
|
1222
|
+
onnxFile: "onnx/model.onnx",
|
|
1223
|
+
onnxDigest: "sha256:828e1496d7fabb79cfa4dcd84fa38625c0d3d21da474a00f08db0f559940cf35"
|
|
1224
|
+
},
|
|
1225
|
+
tokenizer: {
|
|
1226
|
+
kind: "wordpiece-bert",
|
|
1227
|
+
file: "tokenizer.json",
|
|
1228
|
+
digest: "sha256:d241a60d5e8f04cc1b2b3e9ef7a4921b27bf526d9f6050ab90f9267a1f9e5c66"
|
|
1229
|
+
},
|
|
1230
|
+
queryInstruction: "Represent this sentence for searching relevant passages: ",
|
|
1231
|
+
passageInstruction: "",
|
|
1232
|
+
...SHARED_ENCODING
|
|
1233
|
+
};
|
|
1234
|
+
var GEMMA2_REPO = "onnx-community/embeddinggemma-2-ONNX";
|
|
1235
|
+
var GEMMA2_PROCESSOR_CONFIG = {
|
|
1236
|
+
path: "processor_config.json",
|
|
1237
|
+
digest: "sha256:168f6a08522f3ce5dea596d94d003af2fd691742d4f41fe1f9d8cce76bfbf69c"
|
|
1238
|
+
};
|
|
1239
|
+
var EMBEDDINGGEMMA_2_512_1 = {
|
|
1240
|
+
id: "embeddinggemma-2-512@1",
|
|
1241
|
+
model: {
|
|
1242
|
+
repo: GEMMA2_REPO,
|
|
1243
|
+
revision: "daa72c51243991dfcaf9f9137d2c573d8f7790c0",
|
|
1244
|
+
onnxFile: "onnx/model_quantized.onnx",
|
|
1245
|
+
onnxDigest: "sha256:d06edd601f851c633a2519304cbeb8dc6170d7ceb61b436625c17fb9b6e74953",
|
|
1246
|
+
files: [
|
|
1247
|
+
{
|
|
1248
|
+
path: "onnx/model_quantized.onnx_data",
|
|
1249
|
+
digest: "sha256:278a7ff1248c3618e4bd11a607fc54f7bdc7778854230f3956d3f86bd9db4f3b"
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
path: "config.json",
|
|
1253
|
+
digest: "sha256:8d011bfe08b5e345bbe0b81e5c6fd02c381920b345b986047bc2a33ce7b90d1d"
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
path: "tokenizer_config.json",
|
|
1257
|
+
digest: "sha256:17bd5d6e9364ca49a534e1502076593317c298d4a663623091ed45388f004874"
|
|
1258
|
+
}
|
|
1259
|
+
]
|
|
1260
|
+
},
|
|
1261
|
+
tokenizer: {
|
|
1262
|
+
kind: "gemma-bpe",
|
|
1263
|
+
file: "tokenizer.json",
|
|
1264
|
+
digest: "sha256:4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4"
|
|
1265
|
+
},
|
|
1266
|
+
pooling: "mean",
|
|
1267
|
+
normalized: true,
|
|
1268
|
+
dimensions: 512,
|
|
1269
|
+
truncation: { method: "prefix", sourceDimensions: 768 },
|
|
1270
|
+
maxTokens: 512,
|
|
1271
|
+
queryInstruction: "task: search result | query: ",
|
|
1272
|
+
passageInstruction: "title: none | text: ",
|
|
1273
|
+
vectorEncoding: "bit+int8",
|
|
1274
|
+
distance: { stage1: "hamming", stage2: "cosine" },
|
|
1275
|
+
quantization: {
|
|
1276
|
+
int8: { method: "symmetric-linear", scale: 127 },
|
|
1277
|
+
binary: {
|
|
1278
|
+
method: "centered-sign",
|
|
1279
|
+
threshold: 0,
|
|
1280
|
+
packing: "lsb-first",
|
|
1281
|
+
center: [...EMBEDDINGGEMMA_2_512_CENTER]
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
media: {
|
|
1285
|
+
image: {
|
|
1286
|
+
encoder: {
|
|
1287
|
+
onnxFile: "onnx/vision_encoder_quantized.onnx",
|
|
1288
|
+
onnxDigest: "sha256:bb0de2df53a2448a32dc7908a187c168c8afd514d4d6f674f7f46024875fa4e3",
|
|
1289
|
+
files: [
|
|
1290
|
+
{
|
|
1291
|
+
path: "onnx/vision_encoder_quantized.onnx_data",
|
|
1292
|
+
digest: "sha256:3dabd69c0a36e9a8771ad82030dde74daa5a0e02b7047a5d3f3382b1137bab89"
|
|
1293
|
+
},
|
|
1294
|
+
GEMMA2_PROCESSOR_CONFIG
|
|
1295
|
+
]
|
|
1296
|
+
},
|
|
1297
|
+
tokenBudget: 280,
|
|
1298
|
+
resample: "bicubic",
|
|
1299
|
+
alpha: "composite-white"
|
|
1300
|
+
},
|
|
1301
|
+
video: { framesPerSecond: 1, maxFrames: 32, tokenBudgetPerFrame: 140 },
|
|
1302
|
+
audio: {
|
|
1303
|
+
encoder: {
|
|
1304
|
+
onnxFile: "onnx/audio_encoder_quantized.onnx",
|
|
1305
|
+
onnxDigest: "sha256:04a9a9094ba76fb169e4c69be45a4b621580188654d6be59eab860eadcd42d3c",
|
|
1306
|
+
files: [
|
|
1307
|
+
{
|
|
1308
|
+
path: "onnx/audio_encoder_quantized.onnx_data",
|
|
1309
|
+
digest: "sha256:aa6361d898e1f1d6303f8dd2b5fabf4fd3629e15fd709e9cb06ac5cb9416a030"
|
|
1310
|
+
},
|
|
1311
|
+
GEMMA2_PROCESSOR_CONFIG
|
|
1312
|
+
]
|
|
1313
|
+
},
|
|
1314
|
+
sampleRate: 16e3,
|
|
1315
|
+
channels: 1,
|
|
1316
|
+
maxWindowMs: 3e4
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
var KNOWLEDGE_EMBEDDING_PROFILES = [
|
|
1321
|
+
EMBEDDINGGEMMA_2_512_1,
|
|
1322
|
+
MULTILINGUAL_E5_SMALL_2,
|
|
1323
|
+
MULTILINGUAL_E5_SMALL_1,
|
|
1324
|
+
BGE_SMALL_EN_V15_1
|
|
1325
|
+
];
|
|
1326
|
+
function knowledgeEmbeddingProfile(id) {
|
|
1327
|
+
return KNOWLEDGE_EMBEDDING_PROFILES.find((p) => p.id === id) ?? null;
|
|
1328
|
+
}
|
|
1329
|
+
var QUERY_MODEL_DOWNLOAD_BYTES = {
|
|
1330
|
+
"embeddinggemma-2-512@1": 346397233,
|
|
1331
|
+
"multilingual-e5-small@2": 487352364,
|
|
1332
|
+
"multilingual-e5-small@1": 487352364,
|
|
1333
|
+
"bge-small-en-v1.5@1": 133805935
|
|
1334
|
+
};
|
|
1335
|
+
function knowledgeProfileQueryModelBytes(id) {
|
|
1336
|
+
return QUERY_MODEL_DOWNLOAD_BYTES[id] ?? null;
|
|
1337
|
+
}
|
|
1338
|
+
var MARKDOWN_CHUNKS_2 = {
|
|
1339
|
+
id: "markdown-chunks@2",
|
|
1340
|
+
unit: "tokens",
|
|
1341
|
+
tokenizer: "profile",
|
|
1342
|
+
target: 420,
|
|
1343
|
+
overlap: 64,
|
|
1344
|
+
contextHeader: { max: 64 }
|
|
1345
|
+
};
|
|
1346
|
+
var GEZEL_MULTILINGUAL_E5_SMALL_1 = MULTILINGUAL_E5_SMALL_1;
|
|
1347
|
+
var GEZEL_BGE_SMALL_EN_V15_1 = BGE_SMALL_EN_V15_1;
|
|
1348
|
+
var GEZEL_MARKDOWN_CHUNKS_2 = MARKDOWN_CHUNKS_2;
|
|
1349
|
+
|
|
1350
|
+
// src/query-stopwords.ts
|
|
1351
|
+
import { QUERY_STOP_WORDS } from "@bendyline/gezk";
|
|
1352
|
+
|
|
1353
|
+
// src/reader/fts-query.ts
|
|
1354
|
+
function contentTokens(query) {
|
|
1355
|
+
const tokens = [
|
|
1356
|
+
...new Set((query.normalize("NFKC").match(/[\p{L}\p{N}_]+/gu) ?? []).slice(0, 16))
|
|
1357
|
+
];
|
|
1358
|
+
const content = tokens.filter((t) => !QUERY_STOP_WORDS.has(t.toLowerCase()));
|
|
1359
|
+
return content.length > 0 ? content : tokens;
|
|
1360
|
+
}
|
|
1361
|
+
function contentFtsQuery(query) {
|
|
1362
|
+
const tokens = contentTokens(query);
|
|
1363
|
+
return tokens.length > 0 ? tokens.map(quoteToken).join(" OR ") : null;
|
|
1364
|
+
}
|
|
1365
|
+
function selectiveFtsQuery(query, rows, rowsMatching) {
|
|
1366
|
+
const tokens = contentTokens(query);
|
|
1367
|
+
if (tokens.length === 0) return null;
|
|
1368
|
+
const counted = tokens.map((token) => {
|
|
1369
|
+
const phrase = quoteToken(token);
|
|
1370
|
+
return { phrase, hits: rowsMatching(phrase) };
|
|
1371
|
+
});
|
|
1372
|
+
const kept = counted.filter((c) => c.hits * 2 <= rows);
|
|
1373
|
+
const chosen = kept.length > 0 ? kept : [counted.reduce((rarest, c) => c.hits < rarest.hits ? c : rarest)];
|
|
1374
|
+
return chosen.map((c) => c.phrase).join(" OR ");
|
|
1375
|
+
}
|
|
1376
|
+
var DOCUMENT_FTS_WEIGHTS = { title: 10, summary: 1, aliases: 5 };
|
|
1377
|
+
var DOCUMENT_FTS_ORDER = `bm25(fts_documents, ${DOCUMENT_FTS_WEIGHTS.title}.0, ${DOCUMENT_FTS_WEIGHTS.summary}.0, ${DOCUMENT_FTS_WEIGHTS.aliases}.0)`;
|
|
1378
|
+
var NAME_STOPWORDS = new Set(
|
|
1379
|
+
"a an the of in on at to for by with from and or nor but as into onto about than then is are was were be been being am do does did done has have had having who whom whose what which when where why how whats wheres it its this that these those there their them they he him his she her hers i me my we us our you your not no yes if so can could would should will shall may might must".split(" ")
|
|
1380
|
+
);
|
|
1381
|
+
var EXACT_TITLE_SCORE = Number.POSITIVE_INFINITY;
|
|
1382
|
+
var SAME_WORDS_SCORE = Number.MAX_VALUE;
|
|
1383
|
+
function quoteToken(token) {
|
|
1384
|
+
return `"${token.replace(/"/g, '""')}"`;
|
|
1385
|
+
}
|
|
1386
|
+
function compareScores(a, b) {
|
|
1387
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
1388
|
+
}
|
|
1389
|
+
export {
|
|
1390
|
+
BGE_SMALL_EN_V15_1,
|
|
1391
|
+
EMBEDDINGGEMMA_2_512_1,
|
|
1392
|
+
GEZEL_BGE_SMALL_EN_V15_1,
|
|
1393
|
+
GEZEL_MARKDOWN_CHUNKS_2,
|
|
1394
|
+
GEZEL_MULTILINGUAL_E5_SMALL_1,
|
|
1395
|
+
KNOWLEDGE_EMBEDDING_PROFILES,
|
|
1396
|
+
KNOWLEDGE_VECTOR_FLOORS,
|
|
1397
|
+
MARKDOWN_CHUNKS_2,
|
|
1398
|
+
MULTILINGUAL_E5_SMALL_1,
|
|
1399
|
+
MULTILINGUAL_E5_SMALL_2,
|
|
1400
|
+
QUERY_STOP_WORDS,
|
|
1401
|
+
asymmetricTopK,
|
|
1402
|
+
buildContextHeader,
|
|
1403
|
+
chunkMarkdownProfile,
|
|
1404
|
+
compareScores,
|
|
1405
|
+
contentFtsQuery,
|
|
1406
|
+
knowledgeEmbeddingProfile,
|
|
1407
|
+
knowledgeProfileQueryModelBytes,
|
|
1408
|
+
passageEmbedInput,
|
|
1409
|
+
selectiveFtsQuery
|
|
1410
|
+
};
|