MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Vector Databases for Embeddings with Pinecone

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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(____)
Edit dan Jalankan Kode