Generating embeddings

Pinecone hosts embedding models so you can generate vectors without managing your own embedding infrastructure. Call pc.inference.embed and pass your text inputs directly.

Basic usage

from pinecone import Pinecone

pc = Pinecone(api_key="your-api-key")

result = pc.inference.embed(
    model="multilingual-e5-large",
    inputs=["The quick brown fox", "A second piece of text"],
    parameters={"input_type": "passage"},
)

for embedding in result:
    print(embedding.values[:5])   # first five values

The parameters dict is model-specific. Common keys:

  • input_type: "query" for search queries, "passage" for documents being indexed.

  • truncate: "END" (default) or "NONE" to raise an error on overlong input.

Discover supported parameters for any model:

info = pc.inference.model.get("multilingual-e5-large")
print(info.supported_parameters)

Response: EmbeddingsList

embed returns an EmbeddingsList containing:

It also supports iteration, as shown above. For sparse embeddings (e.g. pinecone-sparse-english-v0), access sparse_indices and sparse_values instead:

result = pc.inference.embed(
    model="pinecone-sparse-english-v0",
    inputs=["machine learning frameworks"],
)
sparse = result.data[0]
print(sparse.sparse_indices)
print(sparse.sparse_values)

A given embed call returns either all-dense or all-sparse results, never a mix. To build a hybrid (dense + sparse) index, call embed once per model and combine the two result sets yourself.

Using the EmbedModel enum

Use the EmbedModel enum for tab-completion and typo safety:

from pinecone import Pinecone, EmbedModel

pc = Pinecone(api_key="your-api-key")

result = pc.inference.embed(
    model=EmbedModel.Multilingual_E5_Large,
    inputs=["search query"],
    parameters={"input_type": "query"},
)

Batch size

Send multiple inputs in a single call to amortize network overhead. Each model caps how many inputs it accepts per call, reported as max_batch_size on the model info (see pc.inference.model.get above). For larger batches, split inputs into chunks and iterate:

texts = [...]   # potentially hundreds of documents

batch_size = 96   # multilingual-e5-large's max_batch_size
all_embeddings = []
for i in range(0, len(texts), batch_size):
    batch = texts[i : i + batch_size]
    result = pc.inference.embed(model="multilingual-e5-large", inputs=batch)
    all_embeddings.extend(result.data)

Storing embeddings in an index

Extract raw values and upsert into a standard (non-integrated) index:

index = pc.index("product-search")

result = pc.inference.embed(
    model="multilingual-e5-large",
    inputs=["The quick brown fox", "A second piece of text"],
    parameters={"input_type": "passage"},
)
vectors = [
    (f"doc-{i}", emb.values)
    for i, emb in enumerate(result.data)
]
index.upsert(vectors=vectors)

For server-side embedding (no manual embed step), use an integrated index and upsert_records() instead. See Integrated records (server-side embedding).

List available models

models = pc.inference.model.list(type="embed")
print(models.names())