# Schema and vectorization questions

**URL:** <https://forum.weaviate.io/t/schema-and-vectorization-questions/2901>\
**Category:** General\
**Created:** [July 2, 2024, 1:38pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901 "2024-07-02T13:38:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 2, 2024, 1:38pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/1 "2024-07-02T13:38:07Z")

</div>

I have a few questions related to vectorization and schema creation.

1. Does it make sense to have arbitrary number of vectors per object and does Weaviate support that? (NOT talking about named vectors because that is still fixed number of vectors per object). Does the following make sense (if no, why?):  
Consider 4 objects, each object has, say, 5, 1, 10, 8 entries of a certain section A. And 2, 3, 7, 8 entries of another section B respectively, related to it.  
Does it make sense, for object 1 to have 7 vectors, object 2 to be 4 and so on… (Each vector only having a single entry of a single section)? In that case everyone would have different number of vectors.

Is that supported by Weaviate, and more importantly, does it make sense, or would we lose too much context breaking it up into so many small sections?

1. Is there a way to vectorize array properties? Currently the method I use for this is to make it a single block of text and then later when returning format it back as an array, but is there a way to vectorize `text[]` properties directly?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 4, 2024, 9:18pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/2 "2024-07-04T21:18:22Z")

</div>

Hi @aritraban !!

For what I understood, for 1., It doesn’t make sense to have multiple vectors per object.

Let me know if this is what you are after:

Consider you have 1 object from the `Person` collection per person.

One object for me, and one object for you 🙂

Now, you want to create other objects, let’s say, a `Skill` collection, that will be cross referencing a `Person` object .

Let’s say you have 10 skills, and I have 5 skills.

If you want the `Person` object to have the average of all (in your case 10, and in mine 5) skills, you are probably looking for the `ref2vec` module/integration:

> **[ref2vec-centroid | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/ref2vec-centroid)**
>
> Introduction

Here also a nice blog post about it:

> **[What is Ref2Vec and why you need it for your recommendation system | Weaviate...](https://weaviate.io/blog/ref2vec-centroid)**
>
> Weaviate introduces Ref2Vec, a new module that utilises Cross-References for Recommendation!

Other than that, you cannot have arbitrary number of vectors tied to one objects in the same vector index, but you can have the centroid of multiple vectors that are cross referencing “condensed” into the vector of the “parent” object.

Let me know if this something closer to what you are looking.

Thanks!

---

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 4, 2024, 10:48pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/3 "2024-07-04T22:48:30Z")

</div>

What is the use of cross references? Like what is the benefit of adding `Skills` as a collection and cross-referencing it with `Person`, rather than having every object in `Person` schema have a `Skills` property? Could you tell me the difference that would convey?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 5, 2024, 1:56pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/4 "2024-07-05T13:56:48Z")

</div>

Oops! Forgot about the 2. 🙈

I was investigating the array vectorization, and had some findings.

I will bring more info here about this soon 🙂

---

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 9, 2024, 1:57pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/5 "2024-07-09T13:57:31Z")

</div>

Yep @DudaNogueira that would be great.

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 9, 2024, 2:17pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/6 "2024-07-09T14:17:46Z")

</div>

ok, array text will be vectorized.

A nice way to check what ends up as the payload to the vectorizer is to change the base url at query time ([check here](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-openai#query-time-parameters)) using the headers and point it to a service like [https://webhook.site/](https://webhook.site/)

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 9, 2024, 2:20pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/7 "2024-07-09T14:20:29Z")

</div>

@DudaNogueira However the weaviate docs dont state that, they say only text is vectorized. Can we update that then?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 9, 2024, 2:30pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/8 "2024-07-09T14:30:34Z")

</div>

This is the code I used:

```auto
import weaviate
import os
from weaviate import classes as wvc

client = weaviate.connect_to_local(
    headers={
        
        "X-OpenAI-BaseURL": "https://webhook.site/0df6133f-f933-42e4-9a2b-07ff7c5afc69",
        #"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY"),
    }
)

collection = client.collections.create(
    "VectorizeArray",
    properties=[
        wvc.config.Property(name="array", data_type=wvc.config.DataType.TEXT_ARRAY)
    ]
)
collection.data.insert({"array": ["this", "is", "an", "array"]})

```

And this is the payload I received

```auto
{
  "input": [
    "vectorize array this is an array"
  ],
  "model": "text-embedding-ada-002"
}

```

Those are the related docs I have found about this:

- [Pulling back the curtains on text2vec | Weaviate - Vector Database](https://weaviate.io/blog/pulling-back-the-curtains-on-text2vec)
- [Vectorizers and Rerankers | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules#vectorization-with-text2vec--modules)

Have you seen a different doc around?

Thanks!

---

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 9, 2024, 2:33pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/9 "2024-07-09T14:33:59Z")

</div>

![image](https://canada1.discourse-cdn.com/flex027/uploads/weaviate/original/2X/5/593ea78975f0ffd018152bc307cdaa6d57667663.png)  
Its not immediately obvious if arrays (`text[]`) are vectorized and how they are vectorized. Eg: is the input of the array stitched together as a block of text and passed to the vectorizer? I guess in this case we are using the array version of openai’s vectorizer, but just want to understand what happens when we have a mixture of `text` AND `text[]` in the same collection.

I think explicitly stating that would be helpful to understand how text2vec relates to directly using embeddings as I think the formatting of documents can affect the embeddings/searches.

Also, is there a way to visualize/query the “Documents” that are returned with explainScore? In the following:

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/weaviate/original/2X/5/5ed4e33b9ff21e0bc89e287ec78b07b0c7fd0c32.png)

I would like to understand what part of the text made this come up, so how to query that “Document”? Is it just the uuid of the object?

@DudaNogueira

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 9, 2024, 2:48pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/10 "2024-07-09T14:48:21Z")

</div>

This is the resulting payload if you have a text array and a text:

```auto
{
  "input": [
    "vectorize array this is an array this is a text"
  ],
  "model": "text-embedding-ada-002"
}

```

this was the insert instruction:

```python
collection.data.insert({"array_property": ["this", "is", "an", "array"], "text_property": "this is a text"})

```

I have created awareness about this, and we’ll also improve the statements for the nested objects too.

That [explain score](https://weaviate.io/developers/weaviate/api/graphql/additional-properties#explainscore) text comes attached to the object itself.

here is how to get both the object and the explain score:

```python
query = collection.query.hybrid(query="array", return_metadata=wvc.query.MetadataQuery(explain_score=True))
for object in query.objects:
    print("####")
    print(object, object.metadata.explain_score)

```

Let me know if this helps.

Thanks!

---

<div class="post-metadata">

**Author:** ![aritraban](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/aritraban/32/1376_2.png) [@aritraban](https://forum.weaviate.io/u/aritraban)\
**Post date:** [July 9, 2024, 2:49pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/11 "2024-07-09T14:49:51Z")

</div>

@DudaNogueira No, I know how to get the explain score with `_additional` or Metadata. I want to understand what is the “Document uuid” the explainScore is referring to, in my picture above.

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 9, 2024, 8:34pm UTC](https://forum.weaviate.io/t/schema-and-vectorization-questions/2901/12 "2024-07-09T20:34:10Z")

</div>

Oh. That’s strange as it seems to have two `keyword,bm25`

Can you give us a reproducible example?
