1. Learn
  2. /
  3. Courses
  4. /
  5. Vector Databases for Embeddings with Pinecone

Connected

Exercise

Upserting vectors for semantic search

Time to embed some text data and upsert the vectors and metadata into your 'pinecone-datacamp' index! You've be given a dataset named squad_dataset.csv, and a sample of 200 rows has been loaded in the DataFrame, df.

In this exercise, to interact with the OpenAI API to use their embedding model, you don't need to create and use your own API key. A valid OpenAI client has been created for you and assigned to the client variable.

Your task is to embed the text using OpenAI's API and upsert the embeddings and metadata into the Pinecone index under the namespace, squad_dataset.

Instructions

100 XP
  • Initialize the Pinecone client with your API key (the OpenAI client is already available as client).
  • Extract the 'id', 'text', and 'title' metadata from each row in the batch.
  • Encode texts using 'text-embedding-3-small' from OpenAI with dimensionality 1536.
  • Upsert the vectors and metadatas to a namespace called 'squad_dataset'.