# Import the Pinecone library
from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec
import time
# Initialize a Pinecone client with your API key
pc = Pinecone(api_key="YOUR_API_KEY")
# Define a sample dataset where each item has a unique ID and piece of text
data = [
{"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 index
embeddings = pc.inference.embed(
model="llama-text-embed-v2",
inputs=[d['text'] for d in data],
parameters={"input_type": "passage", "truncate": "END"}
)
print(embeddings)
EmbeddingsList(
model='llama-text-embed-v2',
data=[
{'values': [0.04925537109375, -0.01313018798828125, -0.0112762451171875, ...]},
...
],
usage={'total_tokens': 130}
)
Generate vector embeddings for input data. This endpoint uses Pinecone’s hosted embedding models.
# Import the Pinecone library
from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec
import time
# Initialize a Pinecone client with your API key
pc = Pinecone(api_key="YOUR_API_KEY")
# Define a sample dataset where each item has a unique ID and piece of text
data = [
{"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 index
embeddings = pc.inference.embed(
model="llama-text-embed-v2",
inputs=[d['text'] for d in data],
parameters={"input_type": "passage", "truncate": "END"}
)
print(embeddings)
EmbeddingsList(
model='llama-text-embed-v2',
data=[
{'values': [0.04925537109375, -0.01313018798828125, -0.0112762451171875, ...]},
...
],
usage={'total_tokens': 130}
)
# Import the Pinecone library
from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec
import time
# Initialize a Pinecone client with your API key
pc = Pinecone(api_key="YOUR_API_KEY")
# Define a sample dataset where each item has a unique ID and piece of text
data = [
{"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 index
embeddings = pc.inference.embed(
model="llama-text-embed-v2",
inputs=[d['text'] for d in data],
parameters={"input_type": "passage", "truncate": "END"}
)
print(embeddings)
EmbeddingsList(
model='llama-text-embed-v2',
data=[
{'values': [0.04925537109375, -0.01313018798828125, -0.0112762451171875, ...]},
...
],
usage={'total_tokens': 130}
)
Generate embeddings for inputs.
Model-specific parameters.
Show child attributes
Common property used to distinguish between types of data.
"query"
How to handle inputs longer than those supported by the model. If "END", truncate the input sequence at the token limit. If "NONE", return an error when the input exceeds the token limit.
"END"
OK
Embeddings generated for the input
The model used to generate the embeddings
"multilingual-e5-large"
Was this page helpful?