sliftutils 1.4.79 → 1.4.80

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.79",
3
+ "version": "1.4.80",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
package/spec.txt CHANGED
@@ -1,5 +1,42 @@
1
1
 
2
+ Searching
3
+ 1) We want to create something that's database agnostic
4
+ - So I think we need like multiple phases for reading. And for applying it? We need to be able to know all of our reads ahead of time, which we should be able to roughly know. Or at least we'll have multiple stages. That should be fine. I guess we could do it so it actually understands our database. Like it reads, and then if it's not there, it returns. That might be fine too.
2
5
 
6
+ interface Database<Root> {
7
+ readData: <T>(fnc: (root: Root) => T) => T | undefined;
8
+ writeData: <T>(fnc: (root: Root) => T, newValue: T) => void;
9
+ }
10
+ I guess this works. We need multiple stages, so it's gonna have to read in the index, In parallel, and then once it has the full index, then it can do the next step in parallel, etc.
3
11
 
4
12
 
5
- Create a companion large data storage thing. which updates the data less frequently, Where we reference it with unique IDs so we don't have to merge as much and it doesn't have to be as strict. This should allow our large databases to be merged faster, even though they are pretty fast to merge at the moment, but they probably will get slower if we make them 10 times bigger.
13
+ remaining
14
+ 1) The code book creation. We kind of do want to recreate it sometimes. Maybe we can have something that does a full expensive recreation at certain early on points?
15
+ 2) The searching there's a few different stages. Like, we want to search more IVF cells, but then even within the cells, we kind of want to download more of the final embeddings. because the codes aren't gonna to be perfect. So we have to do both at the same time?
16
+
17
+ parts
18
+ p8g8 format (q8), so we can store 2048 dimensions is a bit over 2KB
19
+ IVF cell size 32? PQ index reduces by 32X, and if IVF cells reduce by 32X... then 500K 2KB values (1GB) would still just be... 1MB IVF index, so... that's good.
20
+ 0) In IVF, sample 32, then keep sampling more, up to 128 cells
21
+ 1) Pq 64 index (byte values each, break into 64 groups, always... should work well, For face vectors, they're already really optimized. They have so few dimensions, and so we don't compress it by that much. But for text vectors, they're less compressed, so we compress it more. So it should work in all cases)
22
+ 2) Retraining index on a subset
23
+ - Or... just don't. Freeze after a certain point, and... it might be fine? HMM... Although no, we could allow retraining. It should be cheap enough.
24
+ 3) Split into transaction logs, so we can read the PQ index efficiently, but still update it
25
+ UGH... I mean basically you would just be replicating some of what we actually store on disk, but in our database, which is stupid, but I think we'll probably do it anyway. Basically, just a transaction log. We have to read everything every time, but it should help the speed a little bit...
26
+ - And I think it's fair because it's us saying, hey, we're going to read all this data every time, which the database can't know, so it can't optimize for that, but we can know, and then we can optimize for it
27
+ 4) IVF the pq index to vastly decrease the initial access time
28
+ 5.0) automatically split cells when they get big enough (2X their initial size)
29
+ 5) occasionally regenerate the entire IVF.
30
+ 5.1) Have something to store a subset of the data codes?
31
+ 5.1) Have something that stores some of the data randomly so we can easily access a subset. We won't represent deletions in it. That's fine. This will allow us to rebalance the IVF fairly efficiently.
32
+ - And maybe even slowly move stuff over to the new IVF as we access stuff, we see if it's in the new IVF, and if not, we move it?
33
+ - 10% of the data? And... maybe just the pq index values?
34
+ - Should make retraining the IVF ten times faster and shouldn't affect the recall by too much, especially if we have more cells
35
+ - AND, Maybe we can actually sample less the more data we have. Ramping up to 10%.
36
+ unknown
37
+ exactly how we're going to update the IVF.
38
+ IVF pq index, so we can read part of it
39
+ mini transaction logs in each cell?
40
+
41
+ BUT... how do we update IVF
42
+
@@ -12,6 +12,13 @@ import { WebSocketServer, WebSocket } from "ws";
12
12
  import { BulkDatabaseBase, bulkDatabase2Timing, noopReactiveDeps, BULK_ROOT_FOLDER } from "./BulkDatabase2/BulkDatabaseBase";
13
13
  import { wrapHandle, NodeJSDirectoryHandleWrapper, DirectoryWrapper } from "./FileFolderAPI";
14
14
 
15
+ process.on("uncaughtException", err => {
16
+ console.error(`[writeServer] uncaughtException (continuing):`, (err as Error).stack ?? err);
17
+ });
18
+ process.on("unhandledRejection", reason => {
19
+ console.error(`[writeServer] unhandledRejection (continuing):`, (reason as Error)?.stack ?? reason);
20
+ });
21
+
15
22
  // Remote file server for sliftutils getRemoteFileStorage / BulkDatabase2. Serves one folder on disk over
16
23
  // self-signed HTTPS, authenticated with an auto-generated 6-word password (sent as
17
24
  // `Authorization: Bearer <password>`). Run it with `yarn filehoster <folder>` (or the `filehoster` bin).