Vectors are not loading into the local DB using Python Client V4

Hi There!

I’m new to Weaviate and experimenting with this to see if it’s suitable for my app. I’m following the Quick Start guide on the website and set up a local Weaviate instance (Version 1.22.3) and installed Python Client V4 (Version 4.3b1). Followed the instructions in the guide, but after executing the code. Except for the vectors, the rest of them are loaded. Not sure what I’m missing in my code. The other issue is when I try to retrieve the loaded data, empty properties are returned.

Code to load data:

import json
import requests
import weaviate
import weaviate.classes as wvc
from fastembed.embedding import FlagEmbedding as Embedding

client = weaviate.connect_to_local(
    port=8080,
    grpc_port=50051
)


embedding_model = Embedding(model_name="BAAI/bge-base-en", max_length=512)

if client.collections.exists("new"):
    client.collections.delete("new") 
    questions = client.collections.create(
        name="new",
        vectorizer_config=None,
        generative_config=None,
    )

resp = requests.get(
    "https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json"
)
data = json.loads(resp.text)
question_objs = list()
for i, d in enumerate(data):
    vec = list(embedding_model.embed(d["Question"]))[0]
    print(f"importing question: {i+1}")
    question_objs.append(
        wvc.DataObject(
            properties={
                "answer": d["Answer"],
                "question": d["Question"],
                "category": d["Category"],
                "test": "test",
            },
            vector=vec
        )
    )

questions = client.collections.get("new")
questions.data.insert_many(question_objs)

This is what I see when I check the objects in my http://0.0.0.0:8080/v1/objects:

// http://0.0.0.0:8080/v1/objects

{
  "deprecations": null,
  "objects": [
    {
      "class": "New",
      "creationTimeUnix": 1700214394036,
      "id": "01356742-841d-4278-b406-baf5498c25fc",
      "lastUpdateTimeUnix": 1700214394036,
      "properties": {
        "answer": "DNA",
        "category": "SCIENCE",
        "question": "In 1953 Watson & Crick built a model of the molecular structure of this, the gene-carrying substance",
        "test": "test"
      },
      "vectorWeights": null
    },
...
}

Tried to query the data using the V4 client with the following code:

import json
import weaviate
import weaviate.classes as wvc

client = weaviate.connect_to_local(
    port=8080,
    grpc_port=50051,
)


question = client.collections.get("new")
response = question.query.fetch_objects(limit=3)

print(response)

The response when I execute the above code:

_QueryReturn(objects=[_Object(uuid=UUID('01356742-841d-4278-b406-baf5498c25fc'), metadata=None, properties={}, vector=None), _Object(uuid=UUID('3cbba6a4-f9b1-4c29-b834-2e1e130c7e03'), metadata=None, properties={}, vector=None), _Object(uuid=UUID('6740e41b-a896-4b74-8ae9-5714d8d46653'), metadata=None, properties={}, vector=None)])

Not sure If I’m missing some obvious thing here. I appreciate your support!

Hi @Maruthi, welcome!

Can you run the query again like this:

response = question.query.fetch_objects(limit=3, include_vector=True)

And see if it works?

The vectorWeights are not the vector, so that’s normal. And by default vectors are not fetched due to their size.

2 Likes

Thank you @jphwang . It sure did help resolve the issue I was facing. :vulcan_salute:t5::slightly_smiling_face:

1 Like