Skip to main content
Get started with Cyborg Vector Search in minutes.
1

Install Cyborg Vector Search

Install Cyborg Vector Search on your machine:
# Ensure that Python 3.11 or 3.12 is installed
# Or create a virtual environment with Python 3.11 or 3.12:
conda create -n cyborg-env python=3.12

# Activate the virtual environment:
conda activate cyborg-env

# Install Cyborg Vector Search:
pip install cyborg_vector_search_py -i https://dl.cloudsmith.io/<token>/cyborg/cyborg-vector-search/python/simple/
You will need to replace <token> with your token provided by Cyborg.
2

Create a Client

Create a Cyborg Vector Search client:
import cyborg_vector_search_py as cvs
import secrets

# Using `memory` storage for this example
# `redis` and `postgres` are also supported

index_location = cvs.DBConfig("memory")  # Where encrypted index is stored (for queries)
config_location = cvs.DBConfig("memory") # Where encrypted index config is stored (for config/loading)
items_location = cvs.DBConfig("memory")  # Where item contents are stored (for upsert/get)

# Create a client
client = cvs.Client(index_location, config_location, items_location)
For more info, refer to Create a Client.
3

Create an Encrypted Index

Create an encrypted index with Cyborg Vector Search:
# ... Continuing from the previous step

# Create an IVFFlat index config (can also be IVF/IVFPQ)
# Using an example vector dimension of 128, and number of lists of 1024
index_config = cvs.IndexIVFFlat(dimension=128, n_lists=1024)

# Generate an encryption key for the index
index_key = secrets.token_bytes(32)

# Create an encrypted index
index = client.create_index("my_index", index_key, index_config)
For more info, refer to Create an Encrypted Index.
4

Add Items to Encrypted Index

Add data to the encrypted index via Upsert:
# ... Continuing from the previous step

# Add items to the encrypted index
items = [
    {"id": 1, "vector": [0.1, 0.2, 0.3, 0.4], "item": "Hello!"},
    {"id": 2, "vector": [0.5, 0.6, 0.7, 0.8]}, "item": "Hello!",
    {"id": 3, "vector": [0.9, 0.10, 0.11, 0.12], "item": "Hello!"}
]

index.upsert(items)
For more info, refer to Add Items.
5

Query Encrypted Index

Query the encrypted index for similar vectors.
# ... Continuing from the previous step

# Query the encrypted index
query_vector = [0.1, 0.2, 0.3, 0.4]
results = index.query(query_vector)

# Print the results
for result in results:
    print(f"ID: {result.id}, Distance: {result.distance}")
For more info, refer to Query an Encrypted Index.
6

Retrieve Items from Encrypted Index

Retrieve data from the encrypted index:
# ... Continuing from the previous step

# Retrieve items from the encrypted index
ids = [1, 2, 3]
items = index.get_items(ids)

# Print the items
for i in range(len(ids)):
    print(f"ID: {ids[i]}, Contents: {items[i]}")
For more info, refer to Get Items.
7

Next Steps

Learn more about Cyborg Vector Search:

About Cyborg Vector Search

Learn about the architecture, design and deployment of Cyborg Vector Search.

API Docs

Explore the API reference to learn how to use Cyborg Vector Search in your applications.