Hybrid upserts not working

I’m using the code from the documentation but hybrid upserts do not work.

I created a new index, ensured it was on S1 and it was using dot product. Still no luck.

The error I get: Invalid vector value passed: cannot interpret type

index = pinecone.Index(‘example-index’)

upsert_response = index.upsert(
vectors=[
{‘id’: ‘vec1’,
‘values’: [0.1, 0.2, 0.3, 0.4],
‘metadata’: {‘genre’: ‘drama’},
‘sparse_values’: {
‘indices’: [10, 45, 16],
‘values’: [0.5, 0.5, 0.2]
}},
{‘id’: ‘vec2’,
‘values’: [0.2, 0.3, 0.4, 0.5],
‘metadata’: {‘genre’: ‘action’},
‘sparse_values’: {
‘indices’: [15, 40, 11],
‘values’: [0.4, 0.5, 0.2]
}}
],
na

1 Like

I am also having same issue. I have a index in p1 with dotproduct as metric. I tried follow the exact same code from the documentation. Index dimension is 1k. When I try to upsert sparse and dense (of dimension 3) it throws exception as follows,

HTTP response body: {“code”:3,“message”:“Vector dimension 3 does not match the dimension of the index 1000”,“details”:}

Hi @Mohsin ,

the error you are getting is

Vector dimension 3 does not match the dimension of the index 1000

meaning you are trying to upsert vectors with a dimension of 3 in an index that should be getting vectors of dimension 1000 :slight_smile: Check how long your vector values are (array). In any case, for a successful upsert the dimensions have to match.

Hope this helps

HI Jasper,
Thanks for replying and explaining the error message. I think the error message was self-explanatory. I was lost in understanding how sparse-dense upsert work. In a sparse-dense upsert pinecone is expecting 'values’ and ‘sparse_values’. I was confused with dimension of the final representation. Thanks for calling it out.

For those reading it, index dimension should be same as your ‘values’ dimension (in the context of following code snippet)

Here is the snippet I am trying and the source is: Sparse-dense embeddings
(under the header Sparse-dense vector format). A

index = pinecone.Index(‘example-index’)

upsert_response = index.upsert(
vectors=[
{‘id’: ‘vec1’,
‘values’: [0.1, 0.2, 0.3],
‘metadata’: {‘genre’: ‘drama’},
‘sparse_values’: {
‘indices’: [10, 45, 16],
‘values’: [0.5, 0.5, 0.2]
}},
{‘id’: ‘vec2’,
‘values’: [0.2, 0.3, 0.4],
‘metadata’: {‘genre’: ‘action’},
‘sparse_values’: {
‘indices’: [15, 40, 11],
‘values’: [0.4, 0.5, 0.2]
}}
],
namespace=‘example-namespace’
)