This page shows you how to create a serverless index to store dense or sparse vectors.

You can create an index using the Pinecone console.

Create a dense index

Dense indexes store dense vectors, which are numerical representations of the meaning and relationships of text, images, or other types of data. You use dense indexes for semantic search or in combination with sparse indexes for hybrid search.

You can create a dense index designed for external or integrated vector embedding.

Indexes with integrated embedding do not support updating or importing with text.

If you want to upsert and search with source text and have Pinecone convert it to dense vectors automatically, use the create a dense index with integrated embedding as follows:

  • Provide a name for the index.
  • Set embed.model to one of Pinecone’s hosted embedding models.
  • Set spec.cloud and spec.region to the cloud and region where the index should be deployed.
  • Set embed.field_map to the name of the field in your source document that contains the data for embedding.

Other parameters are optional. See the API reference for details.

# pip install --upgrade pinecone
from pinecone import Pinecone
import time

pc = Pinecone(api_key="YOUR_API_KEY")

index_name = "example-index"

if not pc.has_index(index_name):
    index_model = pc.create_index_for_model(
        name=index_name,
        cloud="aws",
        region="us-east-1",
        embed={
            "model":"multilingual-e5-large",
            "field_map":{"text": "chunk_text"}
        }
    )

print(index_model)

The response will look like this:

{'deletion_protection': 'disabled',
 'dimension': 1024,
 'embed': {'dimension': 1024,
           'field_map': {'text': 'chunk_text'},
           'metric': 'cosine',
           'model': 'multilingual-e5-large',
           'read_parameters': {'input_type': 'query', 'truncate': 'END'},
           'write_parameters': {'input_type': 'passage', 'truncate': 'END'},
           'vector_type': 'dense'},
 'host': 'example-index-govk0nt.svc.aped-4627-b74a.pinecone.io',
 'id': '9e8b39c5-a142-4776-9609-e8612ad03d92',
 'metric': 'cosine',
 'name': 'example-index',
 'spec': {'serverless': {'cloud': 'aws', 'region': 'us-east-1'}},
 'status': {'ready': True, 'state': 'Ready'},
 'tags': None}

Create a sparse index

This feature is in public preview.

Sparse indexes store sparse vectors, which are numerical representations of the words or phrases in a document. You use sparse indexes for lexical search, or in combination with dense indexes for hybrid search.

You can create a sparse index designed for external or integrated vector embedding.

If you want to upsert and search with source text and have Pinecone convert it to sparse vectors automatically, create a sparse index with integrated embedding as follows:

  • Provide a name for the index.
  • Set the cloud and region where the index should be deployed. Only aws in eu-west-1, us-east-1, and us-west-2 are supported at this time.
  • Set embed.model to one of Pinecone’s hosted sparse embedding models.
  • Set embed.field_map to the name of the field in your source document that contains the text for embedding.

Other parameters are optional. See the API reference for details.

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="YOUR_API_KEY")

pc.create_index_for_model(
    name="example-index",
    cloud="aws",
    region="us-east-1",
    embed={
        "model":"pinecone-sparse-english-v0",
        "field_map":{"text": "chunk_text"}
    }
)

Create an index from a backup

You can create a dense or sparse index from a backup. For more details, see Restore an index.

Migrate a pod-based index to serverless

You can migrate a pod-based index to serverless by creating a new serverless index from a collection. For more information, see Migrate a pod-based index to serverless.