No vector found after configuring vectorizer!

Description

I am using a 14-day free trial Weaviate cluster using Python. I created a collection using the following:

client.collections.create(
    "OpenAIEmbeddings",
    vectorizer_config=[
        Configure.NamedVectors.text2vec_openai(
            name="name",
            #source_properties=["name"],
            model='text-embedding-3-small',
            dimensions=1536,
            vectorize_collection_name=False
        )
    ],
    
     properties=[
        Property(
            name="name",
            data_type=DataType.TEXT,
            vectorize_property_name=False,  # Use "title" as part of the value to vectorize,
            skip_vectorization=False,
       
        ),
        Property(
            name="number",
            data_type=DataType.TEXT,
            skip_vectorization=True,  # Don't vectorize this property
            vectorize_property_name=False
        ),
    ]
    # Additional parameters not shown
)

this is what I used to upload all my objects. I made sure that my array is a proper list of tuples

collection = client.collections.get("OpenAIEmbeddings")

with collection.batch.dynamic() as batch:
    for text in texts:
        weaviate_obj = {
            "name": text[0],
            "number": str(text[1]),
        }
        #print(text)
        # The model provider integration will automatically vectorize the object
        batch.add_object(
            properties=weaviate_obj,
            # vector=vector  # Optionally provide a pre-obtained vector
        )

I uploaded the objects but not able to see the corresponding embeddings for it. I tried this to print the vector:

collection = client.collections.get("OpenAIEmbeddings")
response = collection.query.fetch_objects()

for o in response.objects:
    print(o.properties) 
    print(o.metadata.distance)  # Inspect metadata
    print(o.uuid)  # Inspect UUID (returned by default)
    print(o.properties)  # Inspect returned objects
    print('Vector:', o.vector)

I am able to see o.uuid and properties. Even neartext works. It’s just the vector which I am not able to see.

How do I see the embedding vector?
Also how is near-text working if there is no vector? Does it work based on keyword search then?

Hi @SmitNGRA,

I hope you having a good weekend!

Using NamedVectors, you must define it as follow [Manage collections | Weaviate - Vector Database]

Here is an example:

from weaviate.classes.config import Configure, Property, DataType

client.collections.create(
	"Article",
	vectorizer_config=[
		Configure.NamedVectors.text2vec_openai(
			name="title_vector",
			source_properties=["title"],
			model="text-embedding-3-large"
    ),
		Configure.NamedVectors.text2vec_openai(
			name="body_vector",
			source_properties=["body"],
            ),
	],
	properties=[ 
		Property(name="title", data_type=DataType.TEXT),
		Property(name="body", data_type=DataType.TEXT),
			],
	replication_config=Configure.replication(
		factor=3
		)
)

Then I inserted just an object:

article = client.collections.get("Article")
uuid = article.data.insert(
    {
        "title": "VectorDatabases",
        "body": " Weaviate is an open source vector search engine that stores both objects and vectors.",
    })

Let’s check the collection in the dashboard, here is how to retrieve NamedVectors using Vectors:

If I would check by ID: [Read objects | Weaviate - Vector Database]:

collection = client.collections.get("Article")
response = collection.query.fetch_objects()

vector_names = ["title_vector", "body_vector"]

data_object = collection.query.fetch_object_by_id(
    uuid="ee10fe38-2315-4eaa-bcec-fc6c284487e4", 
    include_vector=vector_names  
)

for n in vector_names:
    print(f"Vector '{n}': {data_object.vector[n][:5]}...")

I hope this helps.

1 Like