Embedding model

An EmbeddingModel describes the dimensions, data type, and distance metric of vectors stored in an index. The schema layer uses it as the source of truth to size embedding tensors and select the ranking metric, independently of the embedder that produces vectors at runtime.

The embedder you pass to the Pipeline (see Embedders) produces the vectors; the EmbeddingModel on the schema describes the index. The two must agree on dimensions.

Choose a Mistral or custom embedding model

Choose a Mistral or custom embedding model

There are two flavors, discriminated by type:

  • MistralEmbeddingModel: a model served by the Mistral Embedding API. Pair it with a MistralEmbedder that uses the same model name. Search Toolkit validates dimensions against known presets. A dimension that doesn't match the model name raises a Pydantic ValidationError (wrapping DimensionMismatchError). Pass a MistralEmbeddingPreset to the collection schema to use its defaults, or build it explicitly to override the data type or distance metric:

    from mistralai.search.toolkit.document import Document
    from mistralai.search.toolkit.embedding import (
        DistanceMetric,
        MistralEmbeddingModel,
        MistralEmbeddingPreset,
        VectorDType,
    )
    from mistralai.search.toolkit.mistral_search_index.schema import MistralSearchIndexCollectionSchema
    
    # Pass a preset directly to the schema (dimensions and metric filled in)
    schema = MistralSearchIndexCollectionSchema.from_document_type(
        collection_name="my_collection",
        document_type=Document,
        embedding_model=MistralEmbeddingPreset.MISTRAL_EMBED_DIM_1024,
    )
    
    # Build explicitly to override the dtype or distance metric
    model = MistralEmbeddingPreset.MISTRAL_EMBED_DIM_1024.build_embedding_model(
        dtype=VectorDType.FLOAT16,
        distance_metric=DistanceMetric.INNER_PRODUCT,
    )
    
    # Construct directly (dimensions must match the known preset for that name)
    model = MistralEmbeddingModel(name="mistral-embed", dimensions=1024)
  • CustomEmbeddingModel: any embedding model not served by the Mistral Embedding API, such as a third-party or self-hosted model. Use this type with your own Embedder implementation. You set the dimensions, data type, and distance metric. Search Toolkit doesn't apply preset validation:

    from mistralai.search.toolkit.embedding import CustomEmbeddingModel, DistanceMetric, VectorDType
    
    model = CustomEmbeddingModel(
        name="my-provider/text-embedding-3-small",
        dimensions=1536,
        dtype=VectorDType.FLOAT32,
        distance_metric=DistanceMetric.COSINE,
    )

The discriminated union is exposed as EmbeddingModel, which accepts either flavor.

Use Mistral embedding presets

Use Mistral embedding presets

MistralEmbeddingPreset enumerates the supported Mistral embedding models and carries each one's full name, dimensions, and default distance metric:

PresetFull model nameDimensionsDistance metric
MISTRAL_EMBED_DIM_1024"mistral-embed"1024COSINE
MISTRAL_EMBED_DIM_256"mistral-embed-dim256-2510"256COSINE
MISTRAL_EMBED_DIM_128"mistral-embed-dim128-2510"128COSINE

Resolve a preset from a model name with MistralEmbeddingPreset.from_name("mistral-embed").

Pair each preset with the matching MistralEmbedder constant on the pipeline:

Schema presetEmbedder constant
MISTRAL_EMBED_DIM_1024MODEL_1024_EMBEDDING
MISTRAL_EMBED_DIM_256MODEL_256_EMBEDDING
MISTRAL_EMBED_DIM_128MODEL_128_EMBEDDING
Configure stored vectors

Configure stored vectors

Every EmbeddingModel carries three vector-config fields, also available as the VectorConfig protocol:

FieldTypeDefaultPurpose
dimensionsint(required)Vector dimensionality, from 1 to 4096
dtypeVectorDTypeFLOAT16FLOAT32 or FLOAT16
distance_metricDistanceMetricCOSINECOSINE, INNER_PRODUCT, or L2

The schema layer uses these fields to size the embedding tensor and select the ranking metric (for example, cosine similarity or inner product).

Keep the schema and embedder aligned

Keep the schema and embedder aligned

The EmbeddingModel on the schema describes the index; the embedder you pass to the Pipeline produces the vectors at query and ingestion time. They are separate concerns that must agree on dimensions:

  • A MistralEmbeddingModel on the schema pairs with a MistralEmbedder using the matching MODEL_*_EMBEDDING constant.
  • A CustomEmbeddingModel on the schema pairs with a custom Embedder.

Keep the dimensions in sync. The schema rejects vectors of the wrong size.

See also

See also

  • Embedders: the runtime side that produces vectors.
  • Search index: where the schema and the embedding model live.
  • Mistral Search Index: reference for MistralSearchIndexCollectionSchema(embedding_model=...). The Vespa and Postgres schemas take the same argument.