Changing distance metrics
By default, Pinecone indexes using the cosine similarity distance metric to compute similarity scores between vectors, which are used when querying to find the most similar vectors. Pinecone also supports other distance metrics, including Euclidean distance and the dot product.
The distance metric is set when the index is created, and can't be changed afterwards. In this exercise, you'll practice creating an index that uses the dot product distance metric.
Diese Übung ist Teil des Kurses
Vector Databases for Embeddings with Pinecone
Anleitung zur Übung
- Initialize the Pinecone connection with your API key.
- Create a new index called
"dotproduct-index"
that uses the dot product distance metric. - List your indexes to verify that it has been created and has the correct metric.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
# Create an index that uses the dot product distance metric
pc.create_index(
name="____",
dimension=1536,
____,
spec=ServerlessSpec(
cloud='aws',
region='us-east-1'
)
)
# Print a list of your indexes
print(____)