The first step is to create a dataset for your data. AnnDB provides multiple dataset types which provide out-of-the-box solutions for image similarity search, text semantic search, question answering, or raw approximate nearest neighbours search in case you want to use your own vector embeddings.
Create an API Key
Next, you will need to create an API key to authenticate your client application with the AnnDB API. You can either a universal API key for all datasets, or you can create a dataset-specific API key to limit the access scope.
Install AnnDB
AnnDB provides client implementations in the following languages: Python, Ruby. Clients allow you to modify and search the data stored in your datasets.
pip install anndb-api
gem install anndb_api
Hello, world!
This example application shows, how easy it is to build an image similarity search service with AnnDB in just a few lines of code.
import anndb_api# Create a client instanceclient = anndb_api.Client('<YOUR_API_KEY')# Load the datasetdataset = client.images('<DATASET_NAME>')# Insert the datafor url in img_urls:id= dataset.insert(url, metadata={'src_url': url})# Delete some of itdataset.delete(id)# Query top 5 similar imagesitems = dataset.search_image(img_urls[-1], 5)# Query top 5 similar images using textual queryitems = dataset.search_text('cute puppy', 5)
require'anndb_api'# Create a client instanceclient =AnndbApi::Client.new("<YOUR_API_KEY")# Load the datasetdataset = client.images("<DATASET_NAME>")img_urls.each do|url| id = dataset.insert(url, metadata={ "src_url": url })end# Delete some of itdataset.delete(id)# Query top 5 similar imagesitems = dataset.search_image(img_urls.last,5)# Query top 5 similar images using textual queryitems = dataset.search_text("cute puppy",5)