Create object with named vector without configure in collection

For Create an object with named vectors:
I have different scenario with example of create an object with named vectors(Create objects | Weaviate - Vector Database)
I need to use third party model to generate embedding, and I did not define multiple (named) vectors in my collection, and also some of my properties do not need to have embedding array. how to assign some of the properties with specified vectors ?

Hi @alisha_liu !

Not sure I understood. :thinking:

While creating your collection, you can specify named vectors, and also optionally specify which fields you want to use for generating the embeddings.

Now, if you provide the vector yourself, this property selection isn’t necessary as you are generating the vectors yourself (not sure this is the case).

Also, you can use your own models and use the text2vec-transformers so it points to your own vectorizer model.

Let me know if this helps or please, provide more context (is possible with code examples) so I can help you.

THanks!

Hi @DudaNogueira ,

I am using “weaviate-ts-client” sdk to talk with weaviate database.

For create an object with named vectors, as my understand, there is prerequisite: Must “specify the named vectors, following the collection definition”, otherwise, it does not work.

My question:

If I want to create object with named vectors, but I did not want to “Define multiple(named) vectors” when create class like snapshot from weaviate website, is there an alternative way to achieve my goal?

Question Example:

Below is the code i want to used to create object, there is two properties, one is fileName, no attached embedding on it, the other one is paragraph_text, attached with the embedding which is generated by “amazon.titan-embed-text-v1”, I did not “Define multiple(named) vectors” like snapshot when create class, so it does not work.

await weaviateClient.data
.creator()
.withClassName(index_name)
.withProperties({
fileName: fileName,
paragraph_text: paragraph,
})
.withVectors({
paragraph_text: embeddingArray})
.do();

That would be great if you can give me solution with code snippets, thank you!

Hi!

If you do not specify named vectors, your vector (both when you bring your own vectors or let Weaviate vectorize it for you) will be set as a named vector with the name default.

Let me know if this is what you are looking for.

Thanks!

@DudaNogueira Thanks for answer my question, I am still a little bit confused, my goal is: I already have an empty class without define it’s property, and I want to insert object into this class, this object will have two properties, one is fileName, no attached vectors on it, the other one is paragraph_text, attached with my own vectors ,could you please give me a code example to achieve my goal?

Hi @alisha_liu ! Sorry for the delay here, I was out those days.

The vectors are not attached to properties.

So for example, considering what you mentioned, you can simply insert the data:

import weaviate
from weaviate import classes as wvc
client = weaviate.connect_to_local()

collection = client.collections.create("alisha_liu")
collection.data.insert(
    properties={
        "fileName": "example.pdf",
        "paragraph_text": "This is an example"
    },
    vector=[1,2,3]
)

This will leverage the AUTO SCHEMA and create your schema on the fly and consider that you only have one vector.

Let’s check this object:

query = collection.query.fetch_objects(include_vector=True)
object = query.objects[0]
print(
    object.properties,
    object.vector
)

this will output:

{'fileName': 'example.pdf', 'paragraph_text': 'This is an example'} {'default': [1.0, 2.0, 3.0]}

now, if you want multiple vectors, you will create the collection, specifying the named vectors, and then specify them while inserting.

Let me know if this helps :slight_smile:

@DudaNogueira Thanks for your answer.