JSON error while using custom vectors from Tutorial

Hi I am trying to import custom vectors as shown in the tutorial, i am getting this error:

import requests
url = ‘https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny+vectors.json
resp = requests.get(url)
data = json.loads(resp.text)

Configure batch process

client.batch.configure(batch_size=100)

Configure a batch process

with client.batch as batch:
# Batch import all Questions
for i, d in enumerate(data):
print(f"importing document no: {i+1}")

    properties = {
        "answer": d["Answer"],
        "question": d["Question"],
        "category": d["Category"],
    }

    custom_vector = d["Vector"]
    #print ("custom_vector", custom_vector)
    #print ("len(custom_vector)", len(custom_vector))


    client.batch.add_data_object(
        properties,
        "Ragdocs",
        vector=[custom_vector] 
    )

Error: UnexpectedStatusCodeException: batch response! Unexpected status code: 400, with response body: {‘code’: 400, ‘message’: ‘parsing body body from “” failed, because json: cannot unmarshal array into Go struct field Object.objects.vector of type float32’}.

Hi Tsan!

Welcome to our community! :hugs:

The issue here is that you are passing a list of vectors with one vector, as the vector property, while you need only a vector… that is also a list… of dimensions :confused:

here:

    custom_vector = d["Vector"]
    #....
    client.batch.add_data_object(
        properties,
        "Ragdocs",
        vector=[custom_vector] 
    )

Considering our doc, this is the correct way:

batch.add_data_object(properties, "Question", vector=d["Vector"])

so your code should be:

    client.batch.add_data_object(
        properties,
        "Ragdocs",
        vector=custom_vector
    )

Hope this helps!

Let me know if I can assist your further!

Also, did you know we host a free, weekly workshop?
Join us: Weaviate - vector database

Hi @DudaNogueira

Thank you very much! It works now :slight_smile:

I still cant solve the issue at my end even when I am trying to provide custom vectors

Hi! Do you see any outstanding logs?

Thank you for your prompt response. I have successfully resolved the issue by conducting some research on custom vectors