Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 2.95 KB

README.md

File metadata and controls

70 lines (53 loc) · 2.95 KB

VEC SDK examples: choose one ownership boundary

Each runtime SDK has the same three examples. They intentionally use separate database names so the models do not blur together:

These files are SDK usage samples only. They are not included in either server binary; protocol and server regression coverage remains in test.exe/test.cpp.

Model VEC owns Application owns Query shape
01_relational vector + integer slot ID rows/payloads in a relational DB, keyed by slot ID 0 (ID + distance only)
02_filenames vector + filename label file bytes on the filesystem/object store label only
03_sidecar vector + label + up-to-100KB data blob nothing else for the demonstrated record data only

Implementations are provided for:

Start the matching demo server

Every example uses three-dimensional vectors to keep the code readable. Start one database in another terminal before running its example:

./vec-cpu demo_relational 3 --topk=10
./vec-cpu demo_filenames 3 --topk=10
./vec-cpu demo_sidecar 3 --topk=10

For a fresh database on every run without creating or reading persistence files, add --memory:

./vec-cpu --memory demo_relational 3 --topk=10

The examples and SDK connection code do not change; they still connect using the database name, e.g. demo_relational. All records are discarded when the server exits.

Use vec instead of vec-cpu for GPU storage. GPU QUERY returns up to 16 neighbors. CPU QUERY defaults to 50, and --topk=N configures 1..100. The Python and Node examples retain the first TOP_K returned hits; C++ passes that capacity directly to the SDK decoder. Delphi truncates the returned array. There is currently no per-query server-side k field.

The examples use the default L2 metric, whose reported distance is squared Euclidean distance. Pass each SDK's cosine option when cosine distance is wanted.

The examples expect fresh demo databases because PUSH rejects exact duplicate vectors. Use --memory for disposable runs. In persistent mode, rerunning from scratch requires stopping the server and removing all four matching demo files (.tensors, .meta, .hashes, and .data) before restarting it.

Dependencies

  • Python relational example: standard-library sqlite3; the SDK itself needs NumPy.
  • Node relational example: npm install better-sqlite3; the other Node examples need no package beyond the SDK.
  • C++ relational example: SQLite development library, linked with -lsqlite3.
  • Delphi relational example: FireDAC's SQLite driver. Add sdk to the unit search path for all Delphi examples.

Labels are identifiers, not file access. VEC never opens the filename used in the label example. Sidecar data is opaque bytes and is limited to 102400 bytes. Non-empty data passed directly to PUSH requires a non-empty label.