# Vectorizer and vector index config

:::callout{intent="info" title="Python and JS/TS client - Vectorizer Configuration API Changes"}
Starting with Weaviate Python client `v4.16.0`, the [vectorizer configuration API has been updated](../client-libraries/python.md#vectorizer-api-changes-v4160).\
Starting with Weaviate JS/TS client `v3.8.0`, the [vectorizer configuration API has been updated](../client-libraries/typescript.md#vectorizer-api-changes-v380).

Action required: **Update to the latest client version** and migrate your code to use the [new vectorizer configuration API](vector-config.md#specify-a-vectorizer).
:::

## Specify a vectorizer

Specify a `vectorizer` for a collection.

:::accordion{title="Additional information"}
Collection level settings override default values and general configuration parameters such as [environment variables](../database-configuration/overview.md).

- [Available model integrations](../model-provider-integrations/index.md)
- [Vectorizer configuration references](../reference-configuration/collections.md#vector-configuration)
:::

:::code-group{sync="languages"}
```python title="Python" {5}
from weaviate.classes.config import Configure, Property, DataType

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_openai(),
    properties=[
        Property(name="title", data_type=DataType.TEXT),
        Property(name="body", data_type=DataType.TEXT),
    ],
)
```

```typescript title="JavaScript/TypeScript"
import { vectors, dataType } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  Vectorizer:  "text2vec-openai",
  Properties: []*models.Property{
    {
      Name:     "title",
      DataType: schema.DataTypeText.PropString(),
    },
    {
      Name:     "body",
      DataType: schema.DataTypeText.PropString(),
    },
  },
}
```

```java title="Java"
client.collections.create("Article",
    col -> col.vectorConfig(VectorConfig.text2vecTransformers())
        .properties(Property.text("title"), Property.text("body")));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector("default", v => v.Text2VecTransformers()),
        },
        Properties = [Property.Text("title"), Property.Text("body")],
    }
);
```
:::

## Specify vectorizer settings

:::callout{intent="warning" title=".Vectors.text2vec_xxx with AutoSchema"}
Defining a collection with `Configure.Vectors.text2vec_xxx()` with Python client library `4.16.0`-`4.16.3` will throw an error if no properties are defined and `vectorize_collection_name` is not set to `True`.

This is addressed in `4.16.4` of the Weaviate Python client. See this FAQ entry for more details: [Invalid properties error in Python client versions 4.16.0 to 4.16.3](../others/faq.md#q-invalid-properties-error-when-creating-a-collection-python-client-versions-4160-to-4163).
:::

To configure how a vectorizer works (i.e. what model to use) with a specific collection, set the vectorizer parameters.

:::code-group{sync="languages"}
```python title="Python" {5-7}
from weaviate.classes.config import Configure

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_cohere(
        model="embed-multilingual-v2.0", vectorize_collection_name=True
    ),
)
```

```typescript title="JavaScript/TypeScript"
import { vectors } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  Vectorizer:  "text2vec-cohere",
  ModuleConfig: map[string]interface{}{
    "text2vec-cohere": map[string]interface{}{
      "model":              "embed-multilingual-v2.0",
      "vectorizeClassName": true,
    },
  },
}
```

```java title="Java"
client.collections.create("Article", col -> col.vectorConfig(
    VectorConfig.text2vecCohere(c -> c.model("embed-multilingual-v2.0"))));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector(
                "default",
                v =>
                    v.Text2VecTransformers( 
                    // The available settings depend on the module
                    // inferenceUrl: "http://custom-inference:8080",
                    // vectorizeCollectionName: false
                    )
            ),
        },
        Properties = [Property.Text("title"), Property.Text("body")],
    }
);
```
:::

## Define named vectors

You can define multiple [named vectors](../concepts/data.md#multiple-vector-embeddings-named-vectors) per collection. This allows each object to be represented by multiple vector embeddings, each with its own vector index.

As such, each named vector configuration can include its own vectorizer and vector index settings.

:::code-group{sync="languages"}
```python title="Python" {5-26}
from weaviate.classes.config import Configure, Property, DataType

client.collections.create(
    "ArticleNV",
    vector_config=[
        # Set a named vector with the "text2vec-cohere" vectorizer
        Configure.Vectors.text2vec_cohere(
            name="title",
            source_properties=["title"],  # (Optional) Set the source property(ies)
            vector_index_config=Configure.VectorIndex.hnsw(),  # (Optional) Set vector index options
        ),
        # Set another named vector with the "text2vec-openai" vectorizer
        Configure.Vectors.text2vec_openai(
            name="title_country",
            source_properties=[
                "title",
                "country",
            ],  # (Optional) Set the source property(ies)
            vector_index_config=Configure.VectorIndex.hnsw(),  # (Optional) Set vector index options
        ),
        # Set a named vector for your own uploaded vectors
        Configure.Vectors.self_provided(
            name="custom_vector",
            vector_index_config=Configure.VectorIndex.hnsw(),  # (Optional) Set vector index options
        ),
    ],
    properties=[  # Define properties
        Property(name="title", data_type=DataType.TEXT),
        Property(name="country", data_type=DataType.TEXT),
    ],
)
```

```typescript title="JavaScript/TypeScript"
import { vectors, dataType } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "ArticleNV",
  Description: "Collection of articles with named vectors",
  Properties: []*models.Property{
    {
      Name:     "title",
      DataType: schema.DataTypeText.PropString(),
    },
    {
      Name:     "country",
      DataType: schema.DataTypeText.PropString(),
    },
  },
  VectorConfig: map[string]models.VectorConfig{
    "title": {
      Vectorizer: map[string]interface{}{
        "text2vec-openai": map[string]interface{}{
          "properties": []string{"title"},
        },
      },
      VectorIndexType: "hnsw",
    },
    "title_country": {
      Vectorizer: map[string]interface{}{
        "text2vec-openai": map[string]interface{}{
          "properties": []string{"title", "country"},
        },
      },
      VectorIndexType: "hnsw",
    },
    "custom_vector": {
      Vectorizer: map[string]interface{}{
        "none": map[string]interface{}{},
      },
      VectorIndexType: "hnsw",
    },
  },
}
```

```java title="Java"
// Weaviate
client.collections
    .create("ArticleNV",
        col -> col
            .vectorConfig(
                VectorConfig.text2vecTransformers("title",
                    c -> c.sourceProperties("title")
                        .vectorIndex(Hnsw.of())),
                VectorConfig.text2vecTransformers("title_country",
                    c -> c.sourceProperties("title", "country")
                        .vectorIndex(Hnsw.of())),
                VectorConfig.selfProvided("custom_vector",
                    c -> c.vectorIndex(Hnsw.of()).vectorIndex(Hnsw.of())))
            .properties(Property.text("title"), Property.text("country")));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "ArticleNV",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector(
                "title",
                v => v.Text2VecTransformers(),
                sourceProperties: ["title"],
                index: new VectorIndex.HNSW()
            ),
            Configure.Vector(
                "title_country",
                v => v.Text2VecTransformers(),
                sourceProperties: ["title", "country"],
                index: new VectorIndex.HNSW()
            ),
            Configure.Vector(
                "custom_vector",
                v => v.SelfProvided(),
                index: new VectorIndex.HNSW()
            ),
        },
        Properties = [Property.Text("title"), Property.Text("country")],
    }
);
```
:::

## Add new named vectors

:::callout{intent="info" title="Added in `v1.31`"}
:::

Named vectors can be added to existing collection definitions with named vectors. (This is not possible for collections without named vectors.)

:::code-group{sync="languages"}
```python title="Python"
from weaviate.classes.config import Configure

articles = client.collections.use("Article")

articles.config.add_vector(
    vector_config=Configure.Vectors.text2vec_cohere(
        name="body_vector",
        source_properties=["body"],
    )
)
```

```typescript title="JavaScript/TypeScript"
await articles.config.addVector(
    vectors.text2VecCohere({
        name: "body_vector",
        sourceProperties: ["body"],
    })
)
```

```go title="Go"
// Go support coming soon
```

```java title="Java"
CollectionHandle<Map<String, Object>> collection =
    client.collections.use("ArticleNV");

collection.config.update(
    u -> u.vectorConfig(VectorConfig.text2vecTransformers("title_country",
        c -> c.sourceProperties("title", "country")
            .vectorIndex(Hnsw.of()))));
```

```csharp title="C#"
await articles.Config.AddVector(
    Configure.Vector("body_vector", v => v.Text2VecCohere(), sourceProperties: "body")
);
```
:::

:::callout{intent="warning" title="Objects aren't automatically revectorized"}
Adding a new vector to the collection definition [won't trigger vectorization for existing objects](../concepts/data.md#adding-a-named-vector-after-collection-creation). Only objects created after the vector addition will receive these new vector embeddings.
:::

## Define multi-vector embeddings (e.g. ColBERT, ColPali)

:::callout{intent="info" title="Added in `v1.30`"}
:::

Multi-vector embeddings, also known as multi-vectors, represent a single object with multiple vectors, i.e. a 2-dimensional matrix. Multi-vectors are currently only available for HNSW indexes for named vectors. To use multi-vectors, enable it for the appropriate named vector.

:::code-group{sync="languages"}
```python title="Python" {8-11,14}
from weaviate.classes.config import Configure, Property, DataType

client.collections.create(
    "DemoCollection",
    vector_config=[
        # Example 1 - Use a model integration
        # The factory function will automatically enable multi-vector support for the HNSW index
        Configure.MultiVectors.text2vec_jinaai(
            name="jina_colbert",
            source_properties=["text"],
        ),
        # Example 2 - User-provided multi-vector representations
        # Must explicitly enable multi-vector support for the HNSW index
        Configure.MultiVectors.self_provided(
            name="custom_multi_vector",
        ),
    ],
    properties=[Property(name="text", data_type=DataType.TEXT)],
    # Additional parameters not shown
)
```

```typescript title="JavaScript/TypeScript" {6-9,12}
await client.collections.create({
  name: "DemoCollection",
  vectorizers: [
    // Example 1 - Use a model integration
    // The factory function will automatically enable multi-vector support for the HNSW index
    configure.multiVectors.text2VecJinaAI({
      name: "jina_colbert",
      sourceProperties: ["text"],
    }),
    // Example 2 - User-provided multi-vector representations
    // Must explicitly enable multi-vector support for the HNSW index
    configure.multiVectors.selfProvided({
      name: "custom_multi_vector",
    }),
  ],
  properties: [{ name: "text", dataType: dataType.TEXT }],
  // Additional parameters not shown
})
```

```java title="Java" {4-7,10-11}
client.collections.create("DemoCollection", col -> col.vectorConfig(
    // Example 1 - Use a model integration
    // The factory function will automatically enable multi-vector support for the HNSW index
    VectorConfig.text2multivecJinaAi("jina_colbert",
        vc -> vc.sourceProperties("text")
            // In Java, explicitly configure the HNSW index for multi-vector
            .vectorIndex(Hnsw.of(h -> h.multiVector(MultiVector.of())))),
    // Example 2 - User-provided multi-vector representations
    // Must explicitly enable multi-vector support for the HNSW index
    VectorConfig.selfProvided("custom_multi_vector",
        vc -> vc.vectorIndex(Hnsw.of(h -> h.multiVector(MultiVector.of()))))
).properties(Property.text("text"))
// Additional parameters not shown
);
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "DemoCollection",
        VectorConfig =
        [
            // Example 1 - Use a model integration
            Configure.MultiVector("jina_colbert", v => v.Text2MultiVecJinaAI()),
            // Example 2 - User-provided multi-vector representations
            Configure.MultiVector("custom_multi_vector", v => v.SelfProvided()),
        ],
        Properties = [Property.Text("text")],
    }
);
```
:::

:::callout{intent="tip" title="Use quantization and encoding to compress your vectors"}
Multi-vector embeddings use up more memory than single vector embeddings. You can use [vector quantization](../how-to-configure-weaviate/compression.md) and [encoding](../how-to-configure-weaviate/compression-multi-vectors.md#muvera-encoding) to compress them and reduce memory usage.
:::

## Set vector index type

The [vector index type](../reference-configuration/indexing-vector-index.md) can be set for each collection at creation time, between `hnsw`, `flat`, `dynamic`, and `hfresh` index types.

:::code-group{sync="languages"}
```python title="Python" {7-10}
from weaviate.classes.config import Configure, Property, DataType

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_openai(
        name="default",
        vector_index_config=Configure.VectorIndex.hnsw(),  # Use the HNSW index
        # vector_index_config=Configure.VectorIndex.flat(),  # Use the FLAT index
        # vector_index_config=Configure.VectorIndex.dynamic(),  # Use the DYNAMIC index
        # vector_index_config=Configure.VectorIndex.hfresh(),  # Use the HFRESH index
    ),
    properties=[
        Property(name="title", data_type=DataType.TEXT),
        Property(name="body", data_type=DataType.TEXT),
    ],
)
```

```typescript title="JavaScript/TypeScript"
import { vectors, dataType, configure } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  Properties: []*models.Property{
    {
      Name:     "title",
      DataType: schema.DataTypeText.PropString(),
    },
    {
      Name:     "country",
      DataType: schema.DataTypeText.PropString(),
    },
  },
  Vectorizer:      "text2vec-openai",
  VectorIndexType: "hnsw", // Or "flat", "dynamic", "hfresh"
}
```

```java title="Java"
client.collections.create("Article",
    col -> col
        .vectorConfig(VectorConfig
            .text2vecTransformers(vec -> vec.vectorIndex(Hnsw.of())))
        .properties(Property.text("title"), Property.text("body")));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector(
                "default",
                v => v.Text2VecTransformers(),
                index: new VectorIndex.HNSW()
            ),
        },
        Properties = [Property.Text("title"), Property.Text("body")],
    }
);
```
:::

:::accordion{title="Additional information"}
Read more about index types & compression in:

- [References: Vector index](../reference-configuration/indexing-vector-index.md)
- [Concepts: Vector index](../indexing/vector-index.md)
:::

## Set vector index parameters

Set [vector index parameters](../reference-configuration/indexing-vector-index.md) such as [compression](../how-to-configure-weaviate/compression.md) and [filter strategy](../concepts/filtering.md#filter-strategy) through collection configuration. Some parameters can be [updated later](collection-operations.md#update-a-collection-definition) after collection creation.

:::code-group{sync="languages"}
```python title="Python" {13-17}
from weaviate.classes.config import (
    Configure,
    Property,
    DataType,
    VectorDistances,
    VectorFilterStrategy,
)

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_openai(
        name="default",
        vector_index_config=Configure.VectorIndex.hnsw(
            ef_construction=300,
            distance_metric=VectorDistances.COSINE,
            filter_strategy=VectorFilterStrategy.ACORN,
        ),
    ),
)
```

```typescript title="JavaScript/TypeScript"
import { configure, vectors } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  Properties: []*models.Property{
    {
      Name:     "title",
      DataType: schema.DataTypeText.PropString(),
    },
    {
      Name:     "country",
      DataType: schema.DataTypeText.PropString(),
    },
  },
  Vectorizer:      "text2vec-openai",
  VectorIndexType: "hnsw",
  VectorIndexConfig: map[string]interface{}{
    "bq": map[string]interface{}{
      "enabled": true,
    },
    "efConstruction": 300,
    "distance":       "cosine",
    "filterStrategy": "acorn",
  },
}
```

```java title="Java"
client.collections.create("Article", col -> col
    .vectorConfig(
        VectorConfig.text2vecTransformers(vec -> vec.vectorIndex(Hnsw.of(
            hnsw -> hnsw.efConstruction(300).distance(Distance.COSINE)))))
    .properties(Property.text("title")));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        VectorConfig = new[]
        {
            Configure.Vector(
                "default",
                v => v.Text2VecTransformers(),
                index: new VectorIndex.HNSW()
                {
                    EfConstruction = 300,
                    Distance = VectorDistance.Cosine,
                }
            ),
        },
        Properties = [Property.Text("title")],
    }
);
```
:::

:::accordion{title="Additional information"}
Read more about index types & compression in:

- [References: Vector index](../reference-configuration/indexing-vector-index.md)
- [Concepts: Vector index](../indexing/vector-index.md)
:::

## Property-level settings

Configure individual properties in a collection. Each property can have it's own configuration. Here are some common settings:

- Vectorize the property
- Vectorize the property name
- Set a [tokenization type](../reference-configuration/collections.md#tokenization)

:::code-group{sync="languages"}
```python title="Python" {10-12,17-18}
from weaviate.classes.config import Configure, Property, DataType, Tokenization

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_cohere(),
    properties=[
        Property(
            name="title",
            data_type=DataType.TEXT,
            vectorize_property_name=True,  # Use "title" as part of the value to vectorize
            tokenization=Tokenization.LOWERCASE,  # Use "lowercase" tokenization
            description="The title of the article.",  # Optional description
        ),
        Property(
            name="body",
            data_type=DataType.TEXT,
            skip_vectorization=True,  # Don't vectorize this property
            tokenization=Tokenization.WHITESPACE,  # Use "whitespace" tokenization
        ),
    ],
)
```

```typescript title="JavaScript/TypeScript"
import { vectors, dataType, tokenization } from 'weaviate-client';
```

```go title="Go"
vTrue := true
vFalse := false

articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  Properties: []*models.Property{
    {
      Name:            "title",
      DataType:        schema.DataTypeText.PropString(),
      Tokenization:    "lowercase",
      IndexFilterable: &vTrue,
      IndexSearchable: &vFalse,
      ModuleConfig: map[string]interface{}{
        "text2vec-cohere": map[string]interface{}{
          "vectorizePropertyName": true,
        },
      },
    },
    {
      Name:            "body",
      DataType:        schema.DataTypeText.PropString(),
      Tokenization:    "whitespace",
      IndexFilterable: &vTrue,
      IndexSearchable: &vTrue,
      ModuleConfig: map[string]interface{}{
        "text2vec-cohere": map[string]interface{}{
          "vectorizePropertyName": false,
        },
      },
    },
  },
  Vectorizer: "text2vec-cohere",
}
```

```java title="Java"
client.collections.create("Article",
    col -> col.properties(
        Property.text("title",
            p -> p.description("The title of the article.")
                .tokenization(Tokenization.LOWERCASE)
                .vectorizePropertyName(false)),
        Property.text("body", p -> p.skipVectorization(true)
            .tokenization(Tokenization.WHITESPACE))));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        Properties =
        [
            Property.Text("title", tokenization: PropertyTokenization.Lowercase),
            Property.Text("body", tokenization: PropertyTokenization.Whitespace),
        ],
    }
);
```
:::

## Specify a distance metric

If you choose to bring your own vectors, you should specify the `distance metric`.

:::code-group{sync="languages"}
```python title="Python" {6-8}
from weaviate.classes.config import Configure, VectorDistances

client.collections.create(
    "Article",
    vector_config=Configure.Vectors.text2vec_openai(
        vector_index_config=Configure.VectorIndex.hnsw(
            distance_metric=VectorDistances.COSINE
        ),
    ),
)
```

```typescript title="JavaScript/TypeScript"
import { configure, vectors, vectorDistances } from 'weaviate-client';
```

```go title="Go"
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  VectorIndexConfig: map[string]interface{}{
    "distance": "cosine",
  },
}
```

```java title="Java"
client.collections.create("Article",
    col -> col
        .vectorConfig(VectorConfig.text2vecTransformers(vec -> vec
            .vectorIndex(Hnsw.of(hnsw -> hnsw.distance(Distance.COSINE)))))
        .properties(Property.text("title")));
```

```csharp title="C#"
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        VectorConfig = new[]
        {
            Configure.Vector(
                "default",
                v => v.Text2VecTransformers(),
                index: new VectorIndex.HNSW() { Distance = VectorDistance.Cosine }
            ),
        },
        Properties = [Property.Text("title")],
    }
);
```
:::

:::accordion{title="Additional information"}
For details on the configuration parameters, see the following:

- [Distances](../reference-configuration/distances.md)
- [Vector indexes](../reference-configuration/indexing-vector-index.md)
:::

## Further resources

- [API References: REST: Schema](/weaviate/api/rest#tag/schema/post/schema)
- [References: Configuration: Schema](../reference-configuration/collections.md)
- [Concepts: Data structure](../concepts/data.md)

## Questions and feedback

Have a question or feedback? Here's how to reach us.

::::card-grid
:::card{title="Community Forum" href="https://forum.weaviate.io/c/support" icon="messages-square"}
Ask questions and connect with other developers on our **Community forum**.
:::

:::card{title="Support" href="/guides/support-overview" icon="life-buoy"}
Weaviate Cloud user or customer? Find the right channel on the **Support page**.
:::
::::

## Related pages

- [Agents](./agents-index.md)
- [AI-assisted Weaviate code generation](./ai-assisted-vibe-coding-index.md)
- [APIs](./apis-index.md)
- [Authorization and authentication](./authorization-and-authentication-index.md)
- [Benchmarks](./benchmarks-index.md)
- [Best practices](./best-practices-index.md)
- [Client libraries](./clients-index.md)
- [Client Libraries / SDKs](./client-libraries-index.md)
- [Cloud](./cloud-index.md)
- [Cloud account management](./cloud-account-management-index.md)

# Agent Instructions

This portal answers questions programmatically. To receive a synthesized,
source-cited answer instead of crawling page by page, append the `?ask=`
query parameter to any page URL on this site:

    /guides/quickstart?ask=how+do+I+authenticate

Optional parameters:

- `&goal=<what-you-are-trying-to-do>` steers the answer toward your
  objective (e.g. `&goal=write+a+python+client`).
- `&version=<label>` scopes the answer to a mounted version when the
  portal publishes more than one.

The response is `text/markdown`: the answer followed by a `# Sources` list
of the portal pages it was grounded in. Status codes are the contract:

- `200` — the answer; `402` — the portal owner’s plan or answer credits are
  exhausted (surface this to your operator; do NOT retry); `429` — you are
  rate-limited; back off for the `Retry-After` seconds; `503` — the answer
  lane is temporarily unavailable; fall back to crawling the `.md` pages.

For the full corpus map read `llms.txt` at the site root; for the tool
surface (search + page fetch as MCP tools) see `/mcp`.
