Get startedGet started for free

Returning the most similar vectors

Querying vectors is foundational to so many AI applications. It involves embedding a user input, comparing it to the vectors in the database, and returning the most similar vectors.

In this exercise, you've been provided with a mystery vector called vector and you'll use it to query your index called 'datacamp-index'.

This exercise is part of the course

Vector Databases for Embeddings with Pinecone

View Course

Exercise instructions

  • Initialize the Pinecone connection with your API key.
  • Retrieve the three records with vectors that are most similar to vector.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')

# Retrieve the top three most similar records
query_result = ____

print(query_result)
Edit and Run Code