# Import the Pinecone libraryfrom pinecone.grpc import PineconeGRPC as Pineconefrom pinecone import ServerlessSpecimport time# Initialize a Pinecone client with your API keypc = Pinecone(api_key="YOUR_API_KEY")# Define a sample dataset where each item has a unique ID and piece of textdata = [ {"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."}, {"id": "vec2", "text": "The tech company Apple is known for its innovative products like the iPhone."}, {"id": "vec3", "text": "Many people enjoy eating apples as a healthy snack."}, {"id": "vec4", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, {"id": "vec5", "text": "An apple a day keeps the doctor away, as the saying goes."}, {"id": "vec6", "text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."}]# Convert the text into numerical vectors that Pinecone can indexembeddings = pc.inference.embed( model="llama-text-embed-v2", inputs=[d['text'] for d in data], parameters={"input_type": "passage", "truncate": "END"})print(embeddings)
Generate vector embeddings for input data. This endpoint uses Pinecone’s hosted embedding models.
POST
/
embed
Copy
# Import the Pinecone libraryfrom pinecone.grpc import PineconeGRPC as Pineconefrom pinecone import ServerlessSpecimport time# Initialize a Pinecone client with your API keypc = Pinecone(api_key="YOUR_API_KEY")# Define a sample dataset where each item has a unique ID and piece of textdata = [ {"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."}, {"id": "vec2", "text": "The tech company Apple is known for its innovative products like the iPhone."}, {"id": "vec3", "text": "Many people enjoy eating apples as a healthy snack."}, {"id": "vec4", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, {"id": "vec5", "text": "An apple a day keeps the doctor away, as the saying goes."}, {"id": "vec6", "text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."}]# Convert the text into numerical vectors that Pinecone can indexembeddings = pc.inference.embed( model="llama-text-embed-v2", inputs=[d['text'] for d in data], parameters={"input_type": "passage", "truncate": "END"})print(embeddings)
# Import the Pinecone libraryfrom pinecone.grpc import PineconeGRPC as Pineconefrom pinecone import ServerlessSpecimport time# Initialize a Pinecone client with your API keypc = Pinecone(api_key="YOUR_API_KEY")# Define a sample dataset where each item has a unique ID and piece of textdata = [ {"id": "vec1", "text": "Apple is a popular fruit known for its sweetness and crisp texture."}, {"id": "vec2", "text": "The tech company Apple is known for its innovative products like the iPhone."}, {"id": "vec3", "text": "Many people enjoy eating apples as a healthy snack."}, {"id": "vec4", "text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."}, {"id": "vec5", "text": "An apple a day keeps the doctor away, as the saying goes."}, {"id": "vec6", "text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."}]# Convert the text into numerical vectors that Pinecone can indexembeddings = pc.inference.embed( model="llama-text-embed-v2", inputs=[d['text'] for d in data], parameters={"input_type": "passage", "truncate": "END"})print(embeddings)