WeaviateEx.API.NamedVectors (WeaviateEx v0.7.4)

View Source

Named vectors configuration for multi-vector collections.

Enables creating collections with multiple named vectors, each with its own vectorizer and configuration.

Examples

# Create collection with multiple named vectors
vectorizer_config = NamedVectors.build_vectorizer_config([
  NamedVectors.text2vec_openai(
    name: "title_vector",
    source_properties: ["title"],
    model: "text-embedding-3-small"
  ),
  NamedVectors.text2vec_openai(
    name: "content_vector",
    source_properties: ["content"],
    model: "text-embedding-3-large",
    dimensions: 1024
  ),
  NamedVectors.self_provided(name: "custom_vector")
])

WeaviateEx.Collections.create("Article", %{
  vectorConfig: vectorizer_config,
  properties: [...]
})

Summary

Functions

Build update configs for multiple named vectors.

Build vectorConfig map for collection creation from list of named vector configs.

Create a multi2vec-bind named vector.

Create a multi2vec-clip named vector.

Create a self-provided named vector (no automatic vectorization).

Create a text2vec-azure-openai named vector.

Create a text2vec-cohere named vector.

Create a text2vec-google (Vertex AI) named vector.

Create a text2vec-huggingface named vector.

Create a text2vec-jinaai named vector.

Create a text2vec-mistral named vector.

Create a text2vec-nvidia named vector.

Create a text2vec-ollama named vector.

Create a text2vec-openai named vector.

Create a text2vec-voyageai named vector.

Create an update configuration for an existing named vector.

Convert an update config to API format for Collections.update.

Types

config()

@type config() :: map()

opts()

@type opts() :: keyword()

update_config()

@type update_config() :: %{
  name: String.t(),
  vector_index_config: map() | nil,
  quantizer_config: map() | nil
}

Functions

build_update_config(updates)

@spec build_update_config([update_config()]) :: map()

Build update configs for multiple named vectors.

Examples

updates = NamedVectors.build_update_config([
  NamedVectors.update_config("title_vector", vector_index: [ef: 200]),
  NamedVectors.update_config("content_vector", vector_index: [ef: 150])
])

build_vectorizer_config(named_vectors)

@spec build_vectorizer_config([config()]) :: map()

Build vectorConfig map for collection creation from list of named vector configs.

Examples

configs = [
  NamedVectors.text2vec_openai(name: "title_vector"),
  NamedVectors.self_provided(name: "custom_vector")
]

NamedVectors.build_vectorizer_config(configs)

multi2vec_bind(opts)

@spec multi2vec_bind(opts()) :: config()

Create a multi2vec-bind named vector.

Options

  • :name - Vector name (required)
  • :image_fields - Image property names
  • :text_fields - Text property names
  • :audio_fields - Audio property names
  • :video_fields - Video property names
  • :depth_fields - Depth property names
  • :thermal_fields - Thermal property names
  • :imu_fields - IMU property names

Examples

NamedVectors.multi2vec_bind(name: "bind_vector")

multi2vec_clip(opts)

@spec multi2vec_clip(opts()) :: config()

Create a multi2vec-clip named vector.

Options

  • :name - Vector name (required)
  • :image_fields - Image property names
  • :text_fields - Text property names

Examples

NamedVectors.multi2vec_clip(
  name: "clip_vector",
  image_fields: ["image"],
  text_fields: ["caption"]
)

self_provided(opts)

@spec self_provided(opts()) :: config()

Create a self-provided named vector (no automatic vectorization).

Options

  • :name - Vector name (required)
  • :vector_index_type - Index type: "hnsw", "flat", "dynamic" (default: "hnsw")
  • :hnsw_opts - HNSW index options
  • :quantizer - Quantization config

Examples

NamedVectors.self_provided(name: "custom_vector")

text2vec_azure_openai(opts)

@spec text2vec_azure_openai(opts()) :: config()

Create a text2vec-azure-openai named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :resource_name - Azure resource name (required)
  • :deployment_id - Azure deployment ID (required)
  • :base_url - Custom API endpoint

Examples

NamedVectors.text2vec_azure_openai(
  name: "azure_vector",
  resource_name: "my-resource",
  deployment_id: "my-deployment"
)

text2vec_cohere(opts)

@spec text2vec_cohere(opts()) :: config()

Create a text2vec-cohere named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - Cohere model name
  • :truncate - Truncation mode

Examples

NamedVectors.text2vec_cohere(name: "cohere_vector", model: "embed-v4.0")

text2vec_google_vertex(opts)

@spec text2vec_google_vertex(opts()) :: config()

Create a text2vec-google (Vertex AI) named vector.

Options

  • :name - Vector name (required)
  • :project_id - Google Cloud project ID (required)
  • :source_properties - Properties to vectorize
  • :model - Model name
  • :api_endpoint - API endpoint

Examples

NamedVectors.text2vec_google_vertex(
  name: "vertex_vector",
  project_id: "my-project"
)

text2vec_huggingface(opts)

@spec text2vec_huggingface(opts()) :: config()

Create a text2vec-huggingface named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - HuggingFace model name
  • :passage_model - Model for passages
  • :query_model - Model for queries
  • :wait_for_model - Wait for model to load
  • :use_gpu - Use GPU inference
  • :use_cache - Use caching

Examples

NamedVectors.text2vec_huggingface(name: "hf_vector")

text2vec_jinaai(opts)

@spec text2vec_jinaai(opts()) :: config()

Create a text2vec-jinaai named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - Jina model name (e.g., "jina-embeddings-v3", "jina-embeddings-v4")
  • :dimensions - Output dimensions
  • :base_url - Custom API endpoint

Examples

NamedVectors.text2vec_jinaai(name: "jina_vector", model: "jina-embeddings-v3")

text2vec_mistral(opts)

@spec text2vec_mistral(opts()) :: config()

Create a text2vec-mistral named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - Mistral model name

Examples

NamedVectors.text2vec_mistral(name: "mistral_vector", model: "mistral-embed")

text2vec_nvidia(opts)

@spec text2vec_nvidia(opts()) :: config()

Create a text2vec-nvidia named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - NVIDIA model name
  • :base_url - Custom API endpoint

Examples

NamedVectors.text2vec_nvidia(name: "nvidia_vector")

text2vec_ollama(opts)

@spec text2vec_ollama(opts()) :: config()

Create a text2vec-ollama named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - Ollama model name
  • :api_endpoint - Ollama API endpoint (default: http://localhost:11434)

Examples

NamedVectors.text2vec_ollama(
  name: "ollama_vector",
  model: "llama2",
  api_endpoint: "http://localhost:11434"
)

text2vec_openai(opts)

@spec text2vec_openai(opts()) :: config()

Create a text2vec-openai named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - OpenAI model name
  • :dimensions - Output dimensions
  • :base_url - Custom API endpoint
  • :vectorize_collection_name - Whether to include collection name (default: true)

Examples

NamedVectors.text2vec_openai(
  name: "title_vector",
  source_properties: ["title"],
  model: "text-embedding-3-small"
)

text2vec_voyageai(opts)

@spec text2vec_voyageai(opts()) :: config()

Create a text2vec-voyageai named vector.

Options

  • :name - Vector name (required)
  • :source_properties - Properties to vectorize
  • :model - VoyageAI model name (e.g., "voyage-3", "voyage-3.5")
  • :truncation - Truncation mode
  • :base_url - Custom API endpoint

Examples

NamedVectors.text2vec_voyageai(name: "voyage_vector", model: "voyage-3")

update_config(name, opts)

@spec update_config(
  String.t(),
  keyword()
) :: update_config()

Create an update configuration for an existing named vector.

This allows updating the vector index parameters (like HNSW ef values) or quantizer settings for an existing named vector in a collection.

Options

  • :vector_index - Vector index settings to update
    • :ef - ef parameter for HNSW search
    • :dynamic_ef_min - Minimum dynamic ef
    • :dynamic_ef_max - Maximum dynamic ef
    • :dynamic_ef_factor - Dynamic ef factor
    • :flat_search_cutoff - Flat search cutoff
  • :quantizer - Quantizer settings to update
    • :type - Quantizer type: :pq, :bq, :sq
    • :segments - Number of segments (PQ)
    • :centroids - Number of centroids (PQ)
    • :training_limit - Training limit
    • :rescore_limit - Rescore limit (BQ)

Examples

# Update HNSW ef parameter
NamedVectors.update_config("title_vector",
  vector_index: [ef: 200, dynamic_ef_max: 500]
)

# Update quantizer
NamedVectors.update_config("content_vector",
  quantizer: [type: :pq, segments: 128]
)

# Update both
NamedVectors.update_config("embedding",
  vector_index: [ef: 150],
  quantizer: [type: :bq, rescore_limit: 200]
)

update_to_api(update)

@spec update_to_api(update_config()) :: map()

Convert an update config to API format for Collections.update.

Examples

update = NamedVectors.update_config("title_vector",
  vector_index: [ef: 200]
)

api_format = NamedVectors.update_to_api(update)
# => %{"vectorConfig" => %{"title_vector" => %{"vectorIndexConfig" => %{"ef" => 200}}}}