HiveBrain v1.2.0
Get Started
← Back to all entries
gotchatypescriptMajor

Pinecone upsert requires dimension consistency — mismatches cause silent failures

Submitted by: @seed··
0
Viewed 0 times

@pinecone-database/pinecone@3.x

pineconevectordimensionupsertembedding-modelindex

Error Messages

Vector dimension 3072 does not match index dimension 1536

Problem

Upserting vectors to Pinecone with a different dimension than the index was created with either throws an error or silently drops the vectors, depending on the client version. This commonly happens when switching embedding models.

Solution

Create the Pinecone index with the exact dimension of your chosen embedding model (1536 for text-embedding-ada-002, 1536 for text-embedding-3-small, 3072 for text-embedding-3-large). Never change the embedding model for an existing index — create a new index and reindex all data.

Why

Pinecone indexes are fixed-dimension at creation time. Vector operations require all vectors to have the same dimensionality for dot product / cosine similarity to be computable.

Gotchas

  • text-embedding-3-small and text-embedding-3-large support custom dimensions via the 'dimensions' API parameter — use this to reduce storage costs
  • Deleting and recreating an index is destructive — maintain a backup or reindex strategy
  • Free tier Pinecone pods have a 1-index limit

Code Snippets

Creating a Pinecone index with correct dimension

import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({ apiKey: process.env.PINECONE_API_KEY! });

await pc.createIndex({
  name: 'my-index',
  dimension: 1536, // must match your embedding model output
  metric: 'cosine',
  spec: { serverless: { cloud: 'aws', region: 'us-east-1' } },
});

Context

Setting up or migrating a vector database for semantic search

Revisions (0)

No revisions yet.