Unable to prepare type ndarray for serialization

Hi! I am receiving the following error in Python when attempting to send data to Pinecone’s index:
Unable to prepare type ndarray for serialization

The code is as follows:

device = ‘cuda’ if torch.cuda.is_available() else ‘cpu’
model = SentenceTransformer(“all-MiniLM-L6-v2”, device=device)
vector = model.encode(paragraph_of_text)
_id = str(id)
metadata = {‘text’: paragraph_of_text}
vectors = [((_id, vector, metadata))]
index = pinecone.Index(“my_index”)
index.upsert(vectors=vectors) <== HERE IS WHERE ERROR OCCURS

appears to be associated with a call stack to:
_create_pinecone_vector: 99.

Thanks for any ideas on how to resolve this!

Figured it out - simply need to turn the model encoding into a list:

vector = model.encode(paragraph_of_text).tolist()

Not sure why the docs don’t mention that. :slight_smile:

1 Like

Hey support,
I am wondering why numpy arrays are not supported as data structures