@polymath-ai/db

0.0.2 • Public • Published

Lightweight vector store for Poylmath.

To use:

import { VectorStore } from "@polymath-ai/db";

// A directory where the database will reside.
// The store will create the directory and populate it with two files:
// - `database.db` -- the duckdb database that stores useful metadata.
// - `vector.idx` -- the hnswlib index that stores the vector index.
const path = "/path/to/store";
// The number of dimensions in the vector.
const dimensions = 1536;
const store = new VectorStore(path, dimensions);

To write bits into it:

const bits = ["array", "of", "bits"];
const writer = await store.createWriter();
await writer.write(bits);

To query:

const query = []; // the vector as an array of numbers
const resultCount = 5; // number of results to return
const reader = await store.createReader();
const results = await reader.search(query, resultCount);

Readme

Keywords

none

Package Sidebar

Install

npm i @polymath-ai/db

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

101 kB

Total Files

15

Last publish

Collaborators

  • kinlan
  • komorama
  • dimitriglazkov
  • dalmaer