Embedder models uses the model type configuration.
The model type configuration accepts attributes model-id, url or path,
and multiple of these can be specified as a single config value, where one is used depending on the deployment environment:
If a model-id is specified and the application is deployed on Vespa Cloud, the model-id is used.
Otherwise, if a url is specified, it is used
Otherwise, path is used.
When using path, the model files must be supplied in the
Vespa application package.
Huggingface Embedder
An embedder using any Huggingface tokenizer,
including multilingual tokenizers,
to produce tokens which is then input to a supplied transformer model in ONNX model format.
The Huggingface embedder is configured in services.xml,
within the container tag:
The maximum number of tokens accepted by the transformer model
numeric
512
transformer-input-ids
One
The name or identifier for the transformer input IDs
string
input_ids
transformer-attention-mask
One
The name or identifier for the transformer attention mask
string
attention_mask
transformer-token-type-ids
One
The name or identifier for the transformer token type IDs. If the model does not use token_type_ids use <transformer-token-type-ids/>
string
token_type_ids
transformer-output
One
The name or identifier for the transformer output
string
last_hidden_state
pooling-strategy
One
How the output vectors of the ONNX model is pooled to obtain a single vector representation. Valid values are mean and cls
string
mean
normalize
One
A boolean indicating whether to normalize the output embedding vector to unit length (length 1). Useful for prenormalized-angulardistance-metric
boolean
false
prepend
Optional
Prepend instructions that are prepended to the text input before tokenization and inference. Useful
for models that have been trained with specific prompt instructions. The instructions are prepended to the input text.
Element <query> - Optional query prepend instruction.
Element <document> - Optional document prepend instruction.
Max length of token sequence the transformer-model can handle
numeric
512
max-query-tokens
One
The maximum number of ColBERT query token embeddings. Queries are padded to this length. Must be lower than max-tokens
numeric
32
max-document-tokens
One
The maximum number of ColBERT document token embeddings. Documents are not padded. Must be lower than max-tokens
numeric
512
transformer-input-ids
One
The name or identifier for the transformer input IDs
string
input_ids
transformer-attention-mask
One
The name or identifier for the transformer attention mask
string
attention_mask
transformer-mask-token
One
The mask token id used for ColBERT query padding
numeric
103
transformer-start-sequence-token
One
The start of sequence token id
numeric
101
transformer-end-sequence-token
One
The end of sequence token id
numeric
102
transformer-pad-token
One
The pad sequence token id
numeric
0
query-token-id
One
The colbert query token marker id
numeric
1
document-token-id
One
The colbert document token marker id
numeric
2
transformer-output
One
The name or identifier for the transformer output
string
contextual
The Vespa colbert-embedder uses [unused0]token id 1 for query-token-id, and [unused1],
token id 2 for document-token-iddocument marker. Document punctuation chars are filtered (not configurable).
The following characters are removed !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~.
Use to point to the tokenizer.json Huggingface tokenizer configuration file.
Also supports language, which is only relevant if one wants to tokenize differently based on the document language.
Use "unknown" for a model to be used for any language (i.e. by default).
Low level ONNX execution model. Valid values are parallel or sequential.
Only relevant for inference on CPU.
See ONNX runtime documentation on threading.
string
sequential
onnx-interop-threads
One
Low level ONNX setting.Only relevant for inference on CPU.
numeric
1
onnx-intraop-threads
One
Low level ONNX setting. Only relevant for inference on CPU.
A native Java implementation of SentencePiece.
SentencePiece breaks text into chunks independent of spaces,
which is robust to misspellings and works with CJK languages.
Prefer the Huggingface tokenizer embedder over this
for better compatibility with Huggingface models.
This is suitable to use in conjunction with custom components,
or the resulting tensor can be used in ranking.
A native Java implementation of
WordPiece,
which is commonly used with BERT models.
Prefer the Huggingface tokenizer embedder
over this for better compatibility with Huggingface models.
This is suitable to use in conjunction with custom components,
or the resulting tensor can be used in ranking.
classMyComponent{@InjectpublicMyComponent(ComponentRegistry<Embedder>embedders){// embedders contains all the embedders configured in your services.xml}}
See a concrete example of using an embedder in a custom searcher in
LLMSearcher.
<containerversion="1.0"><componentid="myEmbedder"class="com.example.MyEmbedder"bundle="the name in artifactId in pom.xml"><configname='com.example.my-embedder'><modelmodel-id="minilm-l6-v2"/><vocabpath="files/vocab.txt"/><myValue>foo</myValue></config></component></container>