examples icon indicating copy to clipboard operation
examples copied to clipboard

[Bug] Missing documentation on creation of ndarray for serialization

Open SID262000 opened this issue 2 years ago • 3 comments

Is this a new bug?

  • [X] I believe this is a new bug
  • [X] I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

The below line of code throws an error Type Error expected ndarray for serialization.

embeddings = model.encode(sentences) embeddings.shape

Expected Behavior

We simply need to convert the model encoding to a list, which will resolve the above array.

Steps To Reproduce

Modify embeddings = model.encode(sentences) to embeddings = model.encode(sentences).tolist()

Relevant log output

No response

Environment

- **OS**:
- **Language version**:
- **Pinecone client version**:

Additional Context

Here's the link to the page which references the above issue: https://www.pinecone.io/learn/series/nlp/dense-vector-embeddings-nlp/

I'm happy to work on this issue and update the documentation as well, feel free to assign it to me

SID262000 avatar Aug 02 '23 04:08 SID262000

Cc @jamescalam for review, Thanks

SID262000 avatar Aug 11 '23 20:08 SID262000

hey @SID262000 — I don't know what exactly is causing the issue here. Performing model.encode(sentences) (assuming sentences is a normal python list) should work — and it would output a numpy array, which allows us to do embeddings.shape as shown. Maybe there is something wrong with the sentences data type here?

jamescalam avatar Oct 16 '23 14:10 jamescalam

Hi @jamescalam, sentences in the above context is a list of strings

SID262000 avatar Nov 20 '23 10:11 SID262000