Skip to content

Embedders ​

The embedder turns text into vectors. You pick it with the embeddings setting, as a string, in the manifest, with --embeddings or with DUCKDB_VECTORS_EMBEDDINGS. This page lists the models, the grammar of the string and the way to add your own.

Prefixes ​

Each prefix selects a back-end. In a manifest, the attributes named <prefix>_<attribute> in the same section configure it.

PrefixRunsAttributesExtraFormer prefix
local:<model>a bundled ONNX model through fastembed, with the core install; local:hashing is the deterministic test embeddernonenonefastembed:
huggingface:<repo>any ONNX repository of the Hugging Face Hubhuggingface_tokennonehf:
bedrock:<model>Amazon Bedrock embeddings, such as bedrock:titan or bedrock:cohere.embed-multilingual-v3bedrock_region, bedrock_profilebedrocknone

The former prefixes stay accepted as aliases, and resolve to the same embedders. The model identifier that the database records does not change, so an existing index is reused and nothing is re-embedded. The prefix openai: is reserved and not implemented. With a batch section, bedrock: embeddings of index run as batch jobs, and an embeddings cache by model and text means that a re-run after a fetch embeds nothing.

Models ​

An embedder is resolved from a string, a prefix:model pair (local:<model>, huggingface:<repo-id>, bedrock:titan) or a bare name (hashing). The default is local:minishlab/potion-multilingual-128M, a static multilingual model that keeps vectors and the DuckDB file as small as possible. The registry is contributor-extensible, so you can register an open or closed, local or cloud backend without touching the core:

python
from duckdb_vectors import register_embedder

register_embedder("mybackend", lambda variant: MyEmbedder(variant))

The local: prefix runs a bundled ONNX model with no torch dependency. Pick the dimension tier that fits your relevance/size budget:

BackendSpecDimensionsUse for
fastembed potion (static, multilingual)local:minishlab/potion-multilingual-128M256default; smallest DB, international docs
fastembed MiniLM (multilingual)local:sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2384balanced multilingual relevance
fastembed mpnet (multilingual)local:sentence-transformers/paraphrase-multilingual-mpnet-base-v2768higher multilingual relevance
fastembed e5-large (multilingual)local:intfloat/multilingual-e5-large1024strongest multilingual relevance
fastembed bge-small (English)local:BAAI/bge-small-en-v1.5384English-only, compact
fastembed bge-large (English)local:BAAI/bge-large-en-v1.51024English-only, strongest
Hugging Face ONNX (any repo)huggingface:<repo-id>, e.g. huggingface:Qwen/Qwen3-Embedding-0.6Bprobedany HF repo shipping ONNX weights
Bedrock Titanbedrock:titan1024cloud embedding
Hashing (deterministic, no deps)hashing384tests and CI only, not relevance

The huggingface:<repo-id> prefix is core (no extra install): it downloads a repository's ONNX weights and tokenizer.json via huggingface_hub, runs them through the ONNX runtime fastembed already vendors, mean-pools by default, and uses last-token pooling for Qwen3-style repos. Use it to load a model fastembed does not bundle. It now loads the large majority of ONNX embedding exports on the Hub, not just single-file sentence-transformer encoders. A repo must publish ONNX weights (for example onnx/model.onnx) for this backend to load it.

The loader handles three ONNX shapes:

  • Simple encoders (bge/e5/sentence-transformers): input_ids / attention_mask (/ token_type_ids) feeding a last_hidden_state output.
  • External-data ONNX: larger exports whose weights live in a sibling model.onnx_data. The loader snapshot-downloads the ONNX folder and co-locates the real files in one directory so the ONNX runtime finds the data file beside the graph.
  • Decoder-style embedding graphs (Qwen3-Embedding and relatives): graphs that declare position_ids and per-layer past_key_values.* cache inputs. The loader synthesizes position_ids from the attention mask, feeds zero-length cache tensors (shapes read from the graph), and selects the hidden-state output by name (never the vocabulary logits).

A worked Qwen example — the repo id carries qwen, so the backend switches to last-token pooling automatically (no pooling argument needed):

python
from duckdb_vectors import VectorStore, index_folder

store = VectorStore(
    db_path="vectors.duckdb",
    backend="huggingface:onnx-community/Qwen3-Embedding-0.6B-ONNX",
)
index_folder(store, "documentation", recursive=True)

onnx-community/Qwen3-Embedding-0.6B-ONNX is an external-data, decoder-style export (external model.onnx_data, position_ids plus 28 layers of KV-cache inputs) that emits a 1024-dimensional last_hidden_state; it exercises every part of the generalized loader. On first use the backend downloads the ONNX weights and tokenizer.json into the huggingface_hub cache (a few hundred megabytes); subsequent runs reuse the cache and need no network. A repo must publish ONNX weights at a path the loader probes (onnx/model.onnx, model.onnx, onnx/model_quantized.onnx, or model_quantized.onnx) in a form the vendored ONNX runtime can run; a repo that ships only PyTorch weights will not load.

Which model and dimension should I choose? ​

Start with the default, and step up only if relevance on your own corpus falls short. Model choice moves both latency and storage: the cosine scan does work proportional to dimension × chunk count, and the file grows linearly with the dimension.

The default, local:minishlab/potion-multilingual-128M, is a 256-dimension static Model2Vec model: it embeds a query in ~0.1-0.3 ms, keeps the file smallest, and serves multilingual documentation. A contextual (transformer) model such as the MiniLM, mpnet, or e5 tiers ranks better on nuanced or ambiguous queries, at the cost of a larger vector, a larger file, a slower scan, and a much slower embed, which then dominates both query time and indexing time.

Measured candidates (embed p50 over 20 iterations; hit@k is a small fixed multilingual relevance sanity check, not a full benchmark; produced by scripts/benchmark_embedders.py):

ModelDimensionsEmbed p50hit@1hit@3
local:minishlab/potion-multilingual-128M (default)2560.1 ms0.801.00
local:sentence-transformers/paraphrase-multilingual-MiniLM-L12-v23844.2 ms0.801.00
local:sentence-transformers/paraphrase-multilingual-mpnet-base-v276811.2 ms0.801.00
local:intfloat/multilingual-e5-large102435.6 ms0.801.00
local:BAAI/bge-small-en-v1.53844.0 ms0.801.00
local:BAAI/bge-large-en-v1.5102435.2 ms1.001.00
huggingface:onnx-community/Qwen3-Embedding-0.6B-ONNX102444.1 ms1.001.00
huggingface:onnx-community/embeddinggemma-300m-ONNX768~23 ms0.801.00

The two huggingface: rows run through the generalized Hugging Face loader. Qwen3-Embedding is a decoder-style export with external weights; at 1,024 dims and ~44 ms it is the slowest and largest option, and the only one to reach hit@1 1.00 on the multilingual bank. EmbeddingGemma bakes pooling and its projection heads into the graph, and the loader reads that final output directly; reading the raw backbone instead drops hit@1 to 0.60. Measure on your own corpus before trading the default's size and speed for a larger model.

The Bedrock extra ​

bedrock:titan calls Amazon Bedrock and needs boto3. Install it with the bedrock extra:

shell
$ pip install "duckdb-vectors[bedrock]"

See also ​