@yaks/embedding 0.0.0-stage → 0.2.36

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.
Files changed (132) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +549 -2
  3. package/_dist/compile.d.ts +34 -0
  4. package/_dist/compile.d.ts.map +1 -0
  5. package/_dist/ddl.d.ts +31 -0
  6. package/_dist/ddl.d.ts.map +1 -0
  7. package/_dist/embedder.d.ts +55 -0
  8. package/_dist/embedder.d.ts.map +1 -0
  9. package/_dist/fields.d.ts +70 -0
  10. package/_dist/fields.d.ts.map +1 -0
  11. package/_dist/graph.d.ts +63 -0
  12. package/_dist/graph.d.ts.map +1 -0
  13. package/_dist/held.d.ts +16 -0
  14. package/_dist/held.d.ts.map +1 -0
  15. package/_dist/image.d.ts +20 -0
  16. package/_dist/image.d.ts.map +1 -0
  17. package/_dist/mod.d.ts +105 -0
  18. package/_dist/mod.d.ts.map +1 -0
  19. package/_dist/native.d.ts +20 -0
  20. package/_dist/native.d.ts.map +1 -0
  21. package/_dist/near.d.ts +35 -0
  22. package/_dist/near.d.ts.map +1 -0
  23. package/_dist/neighbours.d.ts +29 -0
  24. package/_dist/neighbours.d.ts.map +1 -0
  25. package/_dist/options.d.ts +37 -0
  26. package/_dist/options.d.ts.map +1 -0
  27. package/_dist/outage.d.ts +64 -0
  28. package/_dist/outage.d.ts.map +1 -0
  29. package/_dist/owed.d.ts +79 -0
  30. package/_dist/owed.d.ts.map +1 -0
  31. package/_dist/remote.d.ts +116 -0
  32. package/_dist/remote.d.ts.map +1 -0
  33. package/_dist/score.d.ts +10 -0
  34. package/_dist/score.d.ts.map +1 -0
  35. package/_dist/search.d.ts +24 -0
  36. package/_dist/search.d.ts.map +1 -0
  37. package/_dist/service.d.ts +23 -0
  38. package/_dist/service.d.ts.map +1 -0
  39. package/_dist/sleeper.d.ts +37 -0
  40. package/_dist/sleeper.d.ts.map +1 -0
  41. package/_dist/sweep.d.ts +71 -0
  42. package/_dist/sweep.d.ts.map +1 -0
  43. package/_dist/tools.d.ts +14 -0
  44. package/_dist/tools.d.ts.map +1 -0
  45. package/_dist/vector.d.ts +30 -0
  46. package/_dist/vector.d.ts.map +1 -0
  47. package/_dist/vocab.d.ts +6 -0
  48. package/_dist/vocab.d.ts.map +1 -0
  49. package/coded.js +98 -0
  50. package/coded.js.map +1 -0
  51. package/coded.ts +85 -0
  52. package/compile.js +145 -0
  53. package/compile.js.map +1 -0
  54. package/compile.ts +206 -0
  55. package/ddl.js +476 -0
  56. package/ddl.js.map +1 -0
  57. package/ddl.ts +346 -0
  58. package/deno.json +1 -0
  59. package/embedder.js +85 -0
  60. package/embedder.js.map +1 -0
  61. package/embedder.ts +113 -0
  62. package/fields.js +178 -0
  63. package/fields.js.map +1 -0
  64. package/fields.ts +259 -0
  65. package/fill.js +177 -0
  66. package/fill.js.map +1 -0
  67. package/fill.ts +144 -0
  68. package/graph.js +113 -0
  69. package/graph.js.map +1 -0
  70. package/graph.ts +167 -0
  71. package/held.js +680 -0
  72. package/held.js.map +1 -0
  73. package/held.ts +726 -0
  74. package/image.js +202 -0
  75. package/image.js.map +1 -0
  76. package/image.ts +185 -0
  77. package/mod.js +105 -0
  78. package/mod.js.map +1 -0
  79. package/mod.ts +113 -0
  80. package/native.js +236 -0
  81. package/native.js.map +1 -0
  82. package/native.ts +288 -0
  83. package/near.js +123 -0
  84. package/near.js.map +1 -0
  85. package/near.ts +192 -0
  86. package/neighbours.js +223 -0
  87. package/neighbours.js.map +1 -0
  88. package/neighbours.ts +303 -0
  89. package/options.js +187 -0
  90. package/options.js.map +1 -0
  91. package/options.ts +269 -0
  92. package/outage.js +128 -0
  93. package/outage.js.map +1 -0
  94. package/outage.ts +132 -0
  95. package/owed.js +287 -0
  96. package/owed.js.map +1 -0
  97. package/owed.ts +346 -0
  98. package/package.json +45 -4
  99. package/remote.js +264 -0
  100. package/remote.js.map +1 -0
  101. package/remote.ts +391 -0
  102. package/score.js +46 -0
  103. package/score.js.map +1 -0
  104. package/score.ts +60 -0
  105. package/search.js +65 -0
  106. package/search.js.map +1 -0
  107. package/search.ts +118 -0
  108. package/service.js +107 -0
  109. package/service.js.map +1 -0
  110. package/service.ts +133 -0
  111. package/sleeper.js +107 -0
  112. package/sleeper.js.map +1 -0
  113. package/sleeper.ts +166 -0
  114. package/sparse.js +36 -0
  115. package/sparse.js.map +1 -0
  116. package/sparse.ts +49 -0
  117. package/sweep.js +374 -0
  118. package/sweep.js.map +1 -0
  119. package/sweep.ts +446 -0
  120. package/tools.js +57 -0
  121. package/tools.js.map +1 -0
  122. package/tools.ts +88 -0
  123. package/vector.js +78 -0
  124. package/vector.js.map +1 -0
  125. package/vector.ts +96 -0
  126. package/visibility.js +83 -0
  127. package/visibility.js.map +1 -0
  128. package/visibility.ts +111 -0
  129. package/vocab.js +22 -0
  130. package/vocab.js.map +1 -0
  131. package/vocab.json +19 -0
  132. package/vocab.ts +22 -0
package/ddl.js ADDED
@@ -0,0 +1,476 @@
1
+ // Canonical vectors, the changes copies held in memory follow, and the
2
+ // embedding queue. An exclusive store notes each changed owner in a set its
3
+ // one process clears; shared storage keeps each vector's int8 codes, which a
4
+ // copy loads from (a fifth of the bytes the floats take), and a journal of
5
+ // every vector written, which each process's copy reads on from (./held.ts).
6
+ import { col, eq, exists, lit, not, NOW, select, table, val } from "@yaks/sql";
7
+ /** The vector table's name. */ export let TABLE = 'embedding';
8
+ /** The exclusive cache generation. Legacy native metadata stays readable by
9
+ * older CLI processes; new searches ignore it. */ export let BUILD = 'embedding_build';
10
+ /** Vectors changed since the exclusive reader refreshed its cache. */ export let DIRTY = 'embedding_dirty';
11
+ /** Each vector's int8 codes, on shared storage. A row is the codes of the
12
+ * vector its owner holds now: triggers delete it when that vector changes or
13
+ * goes, so the table only ever lacks codes, and a scan uses it once it has as
14
+ * many rows as the vectors (./coded.ts). */ export let CODE = 'embedding_code';
15
+ /** The owners of the vectors that have no codes, kept by triggers on both
16
+ * tables whoever writes them, so asking whether every vector has its codes
17
+ * reads one row rather than counting both tables (./coded.ts). */ export let UNCODED = 'embedding_uncoded';
18
+ /** Every vector written or deleted on shared storage, in the order the writes
19
+ * committed: each process's copy reads on from the last change it folded in
20
+ * (./held.ts). Triggers append to it, whoever writes, and the sweep trims all
21
+ * but the newest. */ export let JOURNAL = 'embedding_change';
22
+ /** The queue's name: one row per entity owed a look, and how many writes have
23
+ * queued it since it was last settled. */ export let OWED = 'embedding_owed';
24
+ /** Durable cursors of source tables being reconciled into the queue. */ export let FILL = 'embedding_fill';
25
+ // An upsert keeps one notice per owner even when the outer write replaces
26
+ // rows: a trigger's `insert or ignore` inherits the outer conflict policy.
27
+ let triggers = [
28
+ 'insert',
29
+ 'update',
30
+ 'delete'
31
+ ].map((event)=>({
32
+ t: 'create trigger',
33
+ name: `${DIRTY}_a${event[0]}`,
34
+ ifNot: true,
35
+ timing: 'after',
36
+ event,
37
+ on: TABLE,
38
+ body: [
39
+ {
40
+ t: 'insert',
41
+ into: DIRTY,
42
+ cols: [
43
+ 'owner'
44
+ ],
45
+ rows: [
46
+ [
47
+ col('owner', event == 'delete' ? 'old' : 'new')
48
+ ]
49
+ ],
50
+ upsert: [
51
+ {
52
+ on: [
53
+ col('owner')
54
+ ]
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ }));
60
+ // A vector's codes go with the vector they were made from, whoever writes it.
61
+ let stale = (event)=>({
62
+ t: 'create trigger',
63
+ name: `${CODE}_stale_${event}`,
64
+ ifNot: true,
65
+ timing: 'after',
66
+ event,
67
+ ...event == 'update' ? {
68
+ of: [
69
+ 'vec'
70
+ ]
71
+ } : {},
72
+ on: TABLE,
73
+ body: [
74
+ {
75
+ t: 'delete',
76
+ from: CODE,
77
+ where: eq(col('owner'), col('owner', 'old'))
78
+ }
79
+ ]
80
+ });
81
+ // Each vector written, changed or deleted, journaled in the statement that
82
+ // wrote it.
83
+ let journaled = [
84
+ 'insert',
85
+ 'update',
86
+ 'delete'
87
+ ].map((event)=>({
88
+ t: 'create trigger',
89
+ name: `${JOURNAL}_a${event[0]}`,
90
+ ifNot: true,
91
+ timing: 'after',
92
+ event,
93
+ ...event == 'update' ? {
94
+ of: [
95
+ 'model',
96
+ 'vec'
97
+ ]
98
+ } : {},
99
+ on: TABLE,
100
+ body: [
101
+ {
102
+ t: 'insert',
103
+ into: JOURNAL,
104
+ cols: [
105
+ 'owner'
106
+ ],
107
+ rows: [
108
+ [
109
+ col('owner', event == 'delete' ? 'old' : 'new')
110
+ ]
111
+ ]
112
+ }
113
+ ]
114
+ }));
115
+ /**
116
+ * Heal a store whose vector tables were made while their key was named
117
+ * `entity`: each such table has the column renamed to `owner`, which SQLite
118
+ * carries into every trigger and index that names it. Run it before
119
+ * {@link schema}. It can be deleted once every store has opened with it.
120
+ */ export let rekey = (db)=>{
121
+ for (let name of [
122
+ TABLE,
123
+ DIRTY,
124
+ OWED
125
+ ]){
126
+ let cols = db.query({
127
+ t: 'pragma',
128
+ name: 'table_info',
129
+ arg: name
130
+ });
131
+ if (!cols.some((c)=>c.name == 'entity')) continue;
132
+ db.query({
133
+ t: 'alter table',
134
+ table: name,
135
+ rename: {
136
+ column: 'entity',
137
+ to: 'owner'
138
+ }
139
+ });
140
+ }
141
+ };
142
+ /**
143
+ * The schema the vectors need, as ordered statements. Run them after the
144
+ * component tables exist — the table references the entity spine. Every
145
+ * statement is idempotent, so a table that already exists is left as it is.
146
+ */ export let schema = (ownership = 'exclusive')=>[
147
+ {
148
+ t: 'create table',
149
+ name: TABLE,
150
+ ifNot: true,
151
+ cols: [
152
+ {
153
+ name: 'owner',
154
+ type: 'integer',
155
+ pk: true,
156
+ ref: {
157
+ table: 'entity',
158
+ cols: [
159
+ 'id'
160
+ ]
161
+ }
162
+ },
163
+ {
164
+ name: 'model',
165
+ type: 'text',
166
+ notNull: true
167
+ },
168
+ {
169
+ name: 'hash',
170
+ type: 'text',
171
+ notNull: true
172
+ },
173
+ {
174
+ name: 'vec',
175
+ type: 'blob',
176
+ notNull: true
177
+ },
178
+ {
179
+ name: 'at',
180
+ type: 'text',
181
+ notNull: true,
182
+ default: NOW
183
+ }
184
+ ]
185
+ },
186
+ {
187
+ t: 'create index',
188
+ name: `${TABLE}_model`,
189
+ on: TABLE,
190
+ cols: [
191
+ col('model')
192
+ ],
193
+ ifNot: true
194
+ },
195
+ {
196
+ t: 'create table',
197
+ name: BUILD,
198
+ ifNot: true,
199
+ cols: [
200
+ {
201
+ name: 'id',
202
+ type: 'integer',
203
+ pk: true,
204
+ check: eq(col('id'), lit(1))
205
+ },
206
+ {
207
+ name: 'n',
208
+ type: 'integer',
209
+ notNull: true
210
+ },
211
+ {
212
+ name: 'model',
213
+ type: 'text'
214
+ },
215
+ {
216
+ name: 'dim',
217
+ type: 'integer'
218
+ },
219
+ {
220
+ name: 'rows',
221
+ type: 'integer'
222
+ }
223
+ ]
224
+ },
225
+ // The exclusive cache has not loaded a generation yet.
226
+ {
227
+ t: 'insert',
228
+ or: 'ignore',
229
+ into: BUILD,
230
+ cols: [
231
+ 'id',
232
+ 'n'
233
+ ],
234
+ rows: [
235
+ [
236
+ lit(1),
237
+ lit(0)
238
+ ]
239
+ ]
240
+ },
241
+ ...ownership == 'exclusive' ? tracked() : coded(),
242
+ {
243
+ t: 'create table',
244
+ name: OWED,
245
+ ifNot: true,
246
+ cols: [
247
+ {
248
+ name: 'owner',
249
+ type: 'integer',
250
+ pk: true
251
+ },
252
+ {
253
+ name: 'n',
254
+ type: 'integer',
255
+ notNull: true
256
+ }
257
+ ]
258
+ },
259
+ {
260
+ t: 'create table',
261
+ name: FILL,
262
+ ifNot: true,
263
+ cols: [
264
+ {
265
+ name: 'name',
266
+ type: 'text',
267
+ pk: true
268
+ },
269
+ {
270
+ name: 'after',
271
+ type: 'integer',
272
+ notNull: true
273
+ },
274
+ {
275
+ name: 'last',
276
+ type: 'integer',
277
+ notNull: true
278
+ }
279
+ ]
280
+ }
281
+ ];
282
+ let tracked = ()=>[
283
+ {
284
+ t: 'create table',
285
+ name: DIRTY,
286
+ ifNot: true,
287
+ cols: [
288
+ {
289
+ name: 'owner',
290
+ type: 'integer',
291
+ pk: true
292
+ }
293
+ ]
294
+ },
295
+ ...triggers
296
+ ];
297
+ let coded = ()=>[
298
+ {
299
+ t: 'create table',
300
+ name: CODE,
301
+ ifNot: true,
302
+ cols: [
303
+ {
304
+ name: 'owner',
305
+ type: 'integer',
306
+ pk: true,
307
+ ref: {
308
+ table: 'entity',
309
+ cols: [
310
+ 'id'
311
+ ]
312
+ }
313
+ },
314
+ {
315
+ name: 'code',
316
+ type: 'blob',
317
+ notNull: true
318
+ }
319
+ ]
320
+ },
321
+ {
322
+ // What counting the codes reads: a few bytes a row, not the codes.
323
+ t: 'create index',
324
+ name: `${CODE}_owner`,
325
+ on: CODE,
326
+ cols: [
327
+ col('owner')
328
+ ],
329
+ ifNot: true
330
+ },
331
+ stale('update'),
332
+ stale('delete'),
333
+ {
334
+ t: 'create table',
335
+ name: UNCODED,
336
+ ifNot: true,
337
+ cols: [
338
+ {
339
+ name: 'owner',
340
+ type: 'integer',
341
+ pk: true
342
+ }
343
+ ]
344
+ },
345
+ seed,
346
+ ...uncoded,
347
+ {
348
+ // Autoincrement, so a number is never handed out twice: a copy that has
349
+ // read to change n reads on from n + 1, and a first change past that says
350
+ // the trim took what it had not read.
351
+ t: 'create table',
352
+ name: JOURNAL,
353
+ ifNot: true,
354
+ cols: [
355
+ {
356
+ name: 'seq',
357
+ type: 'integer',
358
+ pk: true,
359
+ autoincrement: true
360
+ },
361
+ {
362
+ name: 'owner',
363
+ type: 'integer',
364
+ notNull: true
365
+ }
366
+ ]
367
+ },
368
+ ...journaled
369
+ ];
370
+ // An owner's codes, or its vector, stand.
371
+ let holds = (name, owner)=>exists(select({
372
+ cols: [
373
+ lit(1)
374
+ ],
375
+ from: table(name),
376
+ where: eq(col('owner'), owner)
377
+ }));
378
+ // Note an owner as uncoded once, when `when` holds.
379
+ let note = (owner, when)=>({
380
+ t: 'insert',
381
+ into: UNCODED,
382
+ cols: [
383
+ 'owner'
384
+ ],
385
+ q: select({
386
+ cols: [
387
+ owner
388
+ ],
389
+ where: when
390
+ }),
391
+ upsert: [
392
+ {
393
+ on: [
394
+ col('owner')
395
+ ]
396
+ }
397
+ ]
398
+ });
399
+ let forget = (owner)=>({
400
+ t: 'delete',
401
+ from: UNCODED,
402
+ where: eq(col('owner'), owner)
403
+ });
404
+ let keep = (on, event, body)=>({
405
+ t: 'create trigger',
406
+ name: `${UNCODED}_${on == TABLE ? 'vector' : 'code'}_${event}`,
407
+ ifNot: true,
408
+ timing: 'after',
409
+ event,
410
+ on,
411
+ body: [
412
+ body
413
+ ]
414
+ });
415
+ // A new vector is uncoded until its codes come, a vector that goes is
416
+ // forgotten, and codes that go while their vector stands (the vector changed,
417
+ // ./stale) leave it uncoded again.
418
+ let uncoded = [
419
+ keep(TABLE, 'insert', note(col('owner', 'new'), not(holds(CODE, col('owner', 'new'))))),
420
+ keep(TABLE, 'delete', forget(col('owner', 'old'))),
421
+ keep(CODE, 'insert', forget(col('owner', 'new'))),
422
+ keep(CODE, 'delete', note(col('owner', 'old'), holds(TABLE, col('owner', 'old'))))
423
+ ];
424
+ // A store whose vectors predate the triggers notes every one that has no
425
+ // codes, once: in the unit that makes the triggers, and only while they are
426
+ // missing. The guard is the outer side of a cross join, so a store that has
427
+ // them reads its catalogue, not its vectors.
428
+ let seed = {
429
+ t: 'insert',
430
+ into: UNCODED,
431
+ cols: [
432
+ 'owner'
433
+ ],
434
+ q: select({
435
+ cols: [
436
+ col('owner', 'e')
437
+ ],
438
+ from: {
439
+ t: 'from',
440
+ as: 'g',
441
+ q: select({
442
+ cols: [
443
+ lit(1)
444
+ ],
445
+ where: not(exists(select({
446
+ cols: [
447
+ lit(1)
448
+ ],
449
+ from: table('sqlite_master'),
450
+ where: eq(col('name'), val(uncoded[0].name))
451
+ })))
452
+ })
453
+ },
454
+ joins: [
455
+ {
456
+ how: 'cross',
457
+ src: table(TABLE, 'e')
458
+ }
459
+ ],
460
+ where: not(exists(select({
461
+ cols: [
462
+ lit(1)
463
+ ],
464
+ from: table(CODE, 'c'),
465
+ where: eq(col('owner', 'c'), col('owner', 'e'))
466
+ })))
467
+ }),
468
+ upsert: [
469
+ {
470
+ on: [
471
+ col('owner')
472
+ ]
473
+ }
474
+ ]
475
+ };
476
+ //# sourceMappingURL=ddl.js.map
package/ddl.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ddl.js","sources":["./ddl.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAE7E,SACE,GAAG,EAEH,EAAE,EACF,MAAM,EAEN,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,EAGN,KAAK,EACL,GAAG,yBAEwB;AAE7B,6BAA6B,GAC7B,OAAO,IAAI,QAAQ,YAAW;AAE9B;gDACgD,GAChD,OAAO,IAAI,QAAQ,kBAAiB;AAEpC,oEAAoE,GACpE,OAAO,IAAI,QAAQ,kBAAiB;AAEpC;;;0CAG0C,GAC1C,OAAO,IAAI,OAAO,iBAAgB;AAElC;;gEAEgE,GAChE,OAAO,IAAI,UAAU,oBAAmB;AAExC;;;mBAGmB,GACnB,OAAO,IAAI,UAAU,mBAAkB;AAEvC;wCACwC,GACxC,OAAO,IAAI,OAAO,iBAAgB;AAElC,sEAAsE,GACtE,OAAO,IAAI,OAAO,iBAAgB;AAElC,0EAA0E;AAC1E,2EAA2E;AAC3E,IAAI,WAAW,AAAC;EAAC;EAAU;EAAU;CAAS,CAAW,GAAG,CAAC,CAC3D,QACkB,CAAC;IACnB,GAAG;IACH,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE;IAC7B,OAAO;IACP,QAAQ;IACR;IACA,IAAI;IACJ,MAAM;MAAC;QACL,GAAG;QACH,MAAM;QACN,MAAM;UAAC;SAAQ;QACf,MAAM;UAAC;YAAC,IAAI,SAAS,SAAS,W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