Quickstart

This guide helps you set up your emno vector database in just a few minutes.

Before you begin

  • Sign Up: If you haven't already, sign up for a free emno account.

On the free Hacker plan, you get one project and two collections, ideal for testing emno and running small applications. You can easily upgrade when you are ready.

1. Get your API Keys

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can generate an API key from your dashboard at any time.

  • Open the emno dashboard.

  • Go to 'API Keys'.

  • Create an API Key and copy it.

2. Install the emno client

To connect with our API, we recommend using one of our official libraries. Currently we support a Node.js client. Alternatively, you're welcome to interact with the API directly if that's more your style.

# Install via NPM
npm install @emno/sdk

Good to know: When using the API directly, remember that each HTTP request should include a 'Token' header with your API key as value. You'll notice this in all our upcoming curl examples.

3. Initialize your connection

Set up your client connection to emno with your API key:

import { Emno } from '@emno/sdk';

const emno = new Emno({
    token: 'your_api_key',
});

4. Create a Collection

In emno, vector embeddings are stored into collections. In each collection, vectors have consistent dimensions and use the same metric to measure similarity.

For instance, you can create a "demoCollection" collection for nearest-neighbor searches, using the Cosine distance metric with vectors of 384 dimensions.

await emno.createCollection({
    name: 'demoCollection',
    config: {
        dim: 384,
        model: 'HUGGINGFACE-MINI-LM-L6',
        algo: "cosine"
        // additional optional configuration parameters
    },
});

5. Insert Vectors

Once your collection is set, insert some sample vectors:

  • Create a client instance that gets the "demoCollection" collection:

const demoCollection = await emno.getCollection('demoCollection');
  • Insert vectors to the collection:

await demoCollection.addText([{
        metadata: {
            source: "user_feedback"
        },
        content: 'The quick brown fox jumps over the lazy dog'
    },
    {
        metadata: {
            source: "user_feedback"
        },
        content: 'Customer service was friendly and solved my issue quickly'
    },
    {
        metadata: {
            source: "article"
        },
        content: 'Sustainable energy solutions are key to future environmental stability'
    },
    {
        metadata: {
            source: "article"
        },
        content: 'Blockchain technology is revolutionizing digital security'
    },
    {
        metadata: {
            source: "news"
        },
        content: 'Global markets react positively to the new economic stimulus package'
    }
]);
const allVectors = await demoCollection.listVectors();
console.log(allVectors);

Note: When adding/updating a large volume of data, the standard practice is to divide it into batches, and perform multiple insert/update operations. With emno, you don't have to worry about batching - emno takes care of that for you!

Run a query in your collection to find vectors that are similar. This example searches for the two nearest vectors to a given text. It uses the Cosine distance metric, the same one you chose when you created the collection.

const queryVectorArray = {
    content: ['technological advancements in energy and security'],
    topK: 2,
};
const queryResultsVectors = await demoCollection.queryByText(queryVectorArray);
console.log(queryResultsVectors);

// Returns:
// [
//     [
//       {
//         "id": "v1",
//         "metadata": {
//           "source": "article"
//         },
//         "content": "Blockchain technology is revolutionizing digital security",
//         "values": [],
//         "distance": 0.5721539258956909,
//         "_client": { .... }
//         "collectionId": "c1"
//       },
//       {
//         "id": "v2",
//         "metadata": {
//           "source": "article"
//         },
//         "content": "Sustainable energy solutions are key to future environmental stability",
//         "values": [],
//         "distance": 0.6308304071426392,
//         "_client": { .... },
//         "collectionId": "c1"
//       }
//     ]
//   ]

7. Cleanup

To delete your "demoCollection":

await emno.deleteCollection('demoCollection');

Warning: Be careful when deleting a collection. Once you delete the collection, you will not be able to use it again.

Next Steps

With your emno account set, and a grasp on the essential operations, check out our examples showcasing the diverse applications of emno. Or, start inserting your own vector embeddings.

Last updated