Skip to main content
Cosine similarity measures the angular relationship between vectors, ignoring magnitude. It is well suited for text embeddings where semantic meaning matters more than vector length.
Before you begin, make sure you have a running VectorAI DB instance.
The following example creates a collection named text_embeddings configured to use cosine similarity as its distance metric.
from actian_vectorai import VectorAIClient, VectorParams, Distance

# Connect to VectorAI DB server
with VectorAIClient("localhost:50051") as client:
    # Create collection with cosine similarity
    client.collections.create(
        "text_embeddings",  # Collection name
        vectors_config=VectorParams(size=128, distance=Distance.Cosine)  # Cosine metric
    )
To confirm the collection was created successfully, call client.collections.get_info("text_embeddings") and check that the status field returns Ready.