Database
- Indexes
- Vectors
- Imports
- Backups
Inference
Assistant
- Assistants
- Files
- Chat
- Evaluation
- Context snippets
Inference
Embed data
Generate embeddings for input data.
For guidance and examples, see Generate embeddings.
POST
/
embed
Copy
# 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="multilingual-e5-large",
inputs=[d['text'] for d in data],
parameters={"input_type": "passage", "truncate": "END"}
)
print(embeddings)
Copy
EmbeddingsList(
model='multilingual-e5-large',
data=[
{'values': [0.04925537109375, -0.01313018798828125, -0.0112762451171875, ...]},
...
],
usage={'total_tokens': 130}
)
Body
application/json
Model-specific parameters.
Common property used to distinguish between types of data.
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.
Response
200 - application/json
Embeddings generated for the input
The embeddings generated for the inputs.
The embedding values.
The model used to generate the embeddings
Was this page helpful?
Copy
# 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="multilingual-e5-large",
inputs=[d['text'] for d in data],
parameters={"input_type": "passage", "truncate": "END"}
)
print(embeddings)
Copy
EmbeddingsList(
model='multilingual-e5-large',
data=[
{'values': [0.04925537109375, -0.01313018798828125, -0.0112762451171875, ...]},
...
],
usage={'total_tokens': 130}
)