Giter Site home page Giter Site logo

imvectordb-vendor-agnostic's Introduction

In-memory VectorDB

Super simple and easy-to-use in-memory vector DB for Node.js

Perfect for quickly building prototypes or small-scale applications in Node.js.

With a compressed (ZIP) file size of just 3KB.

Installation

npm install git+https://github.com/dikarel/imvectordb-vendor-agnostic.git

Usage

You can add documents to the database using your own embedding models.

Here's a complete guide:

import { VectorDB } from 'imvectordb';

const db = new VectorDB();

// Add a new document to the database
db.add({
    id: "1",
    embedding: [0.014970540, ...],
    metadata: {
        text: "original text",
        ... // additional metadata
    }
})

// Perform a search and retrieve the top 10 similar documents
const queryVector = [0.014970540, ...]
const searchResults = await db.query(queryVector, 10)

// Access search result details
searchResults[0].similarity
searchResults[0].document.id
searchResults[0].document.embedding
searchResults[0].document.metadata.text

// Retrieve or delete a document by its ID
db.get("1")
db.del("1")

// Save to or load from a file
db.dumpFile("filename.json")
db.loadFile("filename.json")

// Terminate the Worker when it's no longer needed or when the server closes
db.terminate()

For more examples, please check the "samples" folder and the available types.

Performance

Use up to 10,000 documents; going over is not recommended. A few thousand is ideal.

There's significant room for performance improvement. Patches and PRs are welcome.

Machine: MackBook Air M2
Dimensions: 1,536 (text-embedding-ada)

----------
Search in 100 documents, 10 times.
----------
Total: 57.577ms
Average: 5.758ms

----------
Search in 1000 documents, 10 times.
----------
Total: 541.979ms
Average: 54.198ms

----------
Search in 10000 documents, 10 times.
----------
Total: 13430.621ms
Average: 1343.062ms

Family

  • LLM Chunk
    • Super simple and easy-to-use text splitter for Node.js

License

MIT

imvectordb-vendor-agnostic's People

Contributors

golbin avatar dikarel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.