Using machine-learned models from Vespa Cloud

Vespa Cloud provides a set of machine-learned models that you can use in your applications. These models will always be available on Vespa Cloud and are frozen models. You can also bring your own embedding model, by deploying it in the Vespa application package.

You specify to use a model provided by Vespa Cloud by setting the model-id attribute where you specify a model config. For example, when configuring the Huggingface embedder provided by Vespa, you can write:

<container id="default" version="1.0">
    <component id="e5" type="hugging-face-embedder">
        <transformer-model model-id="e5-small-v2"/>
    </component>
    ...
</container>

With this, your application will have support for text embedding inference for both queries and documents. Nodes that have been provisioned with GPU acceleration, will automatically use GPU for embedding inference.

Vespa Cloud Embedding Models

Models on Vespa model hub are selected open-source embedding models with great performance. See the Massive Text Embedding Benchmark (MTEB) Leaderboard for details. These embedding models are useful for retrieval (semantic search), re-ranking, clustering, classification, and more.

Huggingface Embedder

These models are available for the Huggingface Embedder type="hugging-face-embedder". All these models supports both mapping from string or array<string> to tensor representations. The output tensor cell-precision can be <float> or <bfloat16>.

nomic-ai-modernbert

Trained from ModernBERT-base on the Nomic Embed datasets, bringing the new advances of ModernBERT to embeddings.

Model idnomic-ai-modernbert
Tensor definitiontensor<float>(x[768]) (supports Matryoshka, so x[256] is also possible)
distance-metricangular
Licenseapache-2.0
Sourcehttps://huggingface.co/nomic-ai/modernbert-embed-base @ 92168cb
LanguageEnglish
Component declaration
    <component id="my-embedder-id" type="hugging-face-embedder">
        <transformer-model model-id="nomic-ai-modernbert"/>
        <transformer-output>token_embeddings</transformer-output>
        <max-tokens>8192</max-tokens>
        <prepend>
            <query>search_query:</query>
            <document>search_document:</document>
        </prepend>
    </component>

lightonai-modernbert-large

Trained from ModernBERT-large on the Nomic Embed datasets, bringing the new advances of ModernBERT to embeddings.

Model idlightonai-modernbert-large
Tensor definitiontensor<float>(x[1024])
distance-metricangular
Licenseapache-2.0
Sourcehttps://huggingface.co/lightonai/modernbert-embed-large @ b3a781f
LanguageEnglish
Component declaration
    <component id="my-embedder-id" type="hugging-face-embedder">
        <transformer-model model-id="lightonai-modernbert-large"/>
        <max-tokens>8192</max-tokens>
        <prepend>
            <query>search_query:</query>
            <document>search_document:</document>
        </prepend>
    </component>

alibaba-gte-modernbert

GTE (General Text Embedding) model trained from ModernBERT-base.

Model idalibaba-gte-modernbert
Tensor definitiontensor<float>(x[768]) (supports Matryoshka, so x[256] is also possible)
distance-metricangular
Licenseapache-2.0
Sourcehttps://huggingface.co/Alibaba-NLP/gte-modernbert-base @ 3ab3f8c
LanguageEnglish
Component declaration
    <component id="my-embedder-id" type="hugging-face-embedder">
        <transformer-model model-id="alibaba-gte-modernbert"/>
        <max-tokens>8192</max-tokens>
        <pooling-strategy>cls</pooling-strategy>
    </component>

e5-small-v2

The smallest and most cost-efficient model from the E5 family.

Model-ide5-small-v2
Tensor definitiontensor<float>(x[384]) or tensor<float>(p{},x[384])
distance-metricangular
LicenseMIT
Sourcehttps://huggingface.co/intfloat/e5-small-v2
LanguageEnglish
CommentSee using E5 models

e5-base-v2

The base model of the E5 family.

Model-ide5-base-v2
Tensor definitiontensor<float>(x[768]) or tensor<float>(p{},x[768])
distance-metricangular
LicenseMIT
Sourcehttps://huggingface.co/intfloat/e5-base-v2
LanguageEnglish
CommentSee using E5 models

e5-large-v2

The largest model of the E5 family, at time of writing, this is the best performing embedding model on the MTEB benchmark.

Model-ide5-large-v2
Tensor definitiontensor<float>(x[1024]) or tensor<float>(p{},x[1024])
distance-metricangular
LicenseMIT
Sourcehttps://huggingface.co/intfloat/e5-large-v2
LanguageEnglish
CommentSee using E5 models

multilingual-e5-base

The multilingual model of the E5 family. Use this model for multilingual queries and documents.

Model-idmultilingual-e5-base
Tensor definitiontensor<float>(x[768]) or tensor<float>(p{},x[768])
distance-metricangular
LicenseMIT
Sourcehttps://huggingface.co/intfloat/multilingual-e5-base
LanguageMultilingual
CommentSee using E5 models

Using E5 Models

The E5 family uses keywords with the input to differentiate query and document side embedding.

The query text should be prefixed with "query: ". In this example the original user query is how to format e5 queries.

{
  "yql": "select doc_id from doc where ({targetHits:10}nearestNeighbor(embeddings,e))",
  "input.query(e)": "embed(e5, \"query: how to format e5 queries\")"
}

The same technique also must be applied for document side embedding inference. The input text should be prefixed with "passage: "

field embeddings type tensor<float>(p{}, x[768]) {
  indexing {
    input chunks |
	  for_each {
	    "passage: " . (input title || "") . " " . ( _ || "")
	  } | embed e5 | attribute
  }
}

The above example reads a chunks field of type array<string>, and prefixes each item with "passage: ", followed by the concatenation of the title and the item chunk (_). See execution value example.

Bert Embedder

These models are available for the Bert Embedder type="bert-embedder":

<container id="default" version="1.0">
    <component id="mini" type="bert-embedder">
        <transformer-model model-id="minilm-l6-v2"/>
        <tokenizer-vocab model-id="bert-base-uncased"/>
    </component>
    ...
</container>

Note bert-embedder requires both transformer-model and tokenizer-vocab.

minilm-l6-v2

A small, fast sentence-transformer model.

Model-idminilm-l6-v2
Tensor definitiontensor<float>(x[384]) or tensor<float>(p{},x[384])
distance-metricangular
Licenseapache-2.0
Sourcehttps://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
LanguageEnglish

mpnet-base-v2

A larger, but better than minilm-l6-v2 sentence-transformer model.

Model-idmpnet-base-v2
Tensor definitiontensor<float>(x[768]) or tensor<float>(p{},x[768])
distance-metricangular
Licenseapache-2.0
Sourcehttps://huggingface.co/sentence-transformers/all-mpnet-base-v2
LanguageEnglish

Tokenization Embedders

These are embedder implementations that tokenize text and embed string to the vocabulary identifiers. These are most useful for creating the tensor inputs to re-ranking models that take both the query and document token identifiers as input. Find examples in the sample applications.

bert-base-uncased

A vocabulary text (vocab.txt) file on the format expected by WordPiece: A text token per line.
Model-idbert-base-uncased
Licenseapache-2.0
Sourcehttps://huggingface.co/sentence-transformers/all-MiniLM-L6-v2

e5-base-v2-vocab

A tokenizer.json configuration file on the format expected by HF tokenizer. This tokenizer configuration can be used with e5-base-v2, e5-small-v2 and e5-large-v2.
Model-ide5-base-v2-vocab
LicenseMIT
Sourcehttps://huggingface.co/intfloat/e5-base-v2
LanguageEnglish

multilingual-e5-base-vocab

A tokenizer.json configuration file on the format expected by HF tokenizer. This tokenizer configuration can be used with multilingual-e5-base-vocab.
Model-idmultilingual-e5-base-vocab
LicenseMIT
Sourcehttps://huggingface.co/intfloat/multilingual-e5-base
LanguageMultilingual

Significance models

These are global significance models that can be added to significance element in services.xml.

significance-en-wikipedia-v1

This significance model was generated from English Wikipedia dump data from 2024-08-01. Available in Vespa as of version 8.426.8.
Model-idsignificance-en-wikipedia-v1
LicenseCreative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License.
Sourcehttps://data.vespa-cloud.com/significance_models/significance-en-wikipedia-v1.json.zst
LanguageEnglish

Creating applications working both self-hosted and on Vespa Cloud

You can also specify both a model-id, which will be used on Vespa Cloud, and a url/path, which will be used on self-hosted deployments:

<transformer-model model-id="minilm-l6-v2" path="myAppPackageModels/myModel.onnx"/>

This can be useful for example to create an application package which uses models from Vespa Cloud for production and a scaled-down or dummy model for self-hosted development.

Using Vespa Cloud models with any config

Specifying a model-id can be done for any config field of type model, whether the config is from Vespa or defined by you.