Expand description
FastEmbed - Library for generating vector embeddings and reranking locally.
§What’s here
TextEmbedding- dense text embeddings (default: BGE small en v1.5)SparseTextEmbedding- sparse (SPLADE) embeddings for lexical searchBgem3Embedding- dense + sparse + ColBERT in a single pass (BGE-M3)ImageEmbedding- image embeddings (CLIP, ResNet, …)TextRerank- cross-encoder reranking of candidates
These run on ONNX Runtime and need the onnx feature, which is on by default
and which every ort-* feature turns on.
Qwen3 and Nomic v2 MoE embeddings are available behind the qwen3 and
nomic-v2-moe feature flags (candle backend). A build with
default-features = false and only those features compiles no ONNX Runtime.
qwen3 is qwen3-text (the text embedding model and the reranker, loaded from
local files or GGUF) plus qwen3-vl (the Qwen3-VL image and text model) plus
hf-hub (the from_hf loaders); qwen3-text alone pulls neither hf-hub nor
the image crates.
§Model cache
Models download to ./.fastembed_cache on first use, then load from there.
Override the location with the FASTEMBED_CACHE_DIR env var or
TextInitOptions::with_cache_dir. HF_HOME takes precedence over both.
Set HF_ENDPOINT to pull from a mirror.
§Instantiating TextEmbedding
use fastembed::{TextEmbedding, TextInitOptions, EmbeddingModel};
// With default TextInitOptions
let model = TextEmbedding::try_new(Default::default())?;
// List all supported models
dbg!(TextEmbedding::list_supported_models());
// With custom TextInitOptions
let model = TextEmbedding::try_new(
TextInitOptions::new(EmbeddingModel::AllMiniLML6V2).with_show_download_progress(true),
)?;Find more info about the available options in the TextInitOptions documentation.
§Embeddings generation
let documents = vec![
"passage: Hello, World!",
"query: Hello, World!",
"passage: This is an example passage.",
// You can leave out the prefix but it's recommended
"fastembed-rs is licensed under Apache 2.0"
];
// Generate embeddings with the default batch size, 256
let embeddings = model.embed(documents, None)?;
println!("Embeddings length: {}", embeddings.len()); // -> Embeddings length: 4Re-exports§
pub use crate::output::EmbeddingOutput;onnxpub use crate::output::OutputKey;onnxpub use crate::output::OutputPrecedence;onnxpub use crate::output::SingleBatchOutput;onnx
Modules§
- output
onnx - Utilities to help with the embeddings output.
- similarity
- Similarity helpers for comparing embeddings.
Structs§
- Base
Init Options onnx - Bgem3
Embedding onnx - Rust representation of the BGE-M3 joint embedding model
- Bgem3
Embedding Output onnx - Output of
Bgem3Embedding: dense, sparse (lexical), and ColBERT (multi-vector) representations from a single pass. - Execution
Provider Dispatch onnx - Dynamic execution provider container, used to provide a list of multiple types of execution providers when
configuring execution providers for a
SessionBuilderorEnvironmentBuilder. - Image
Embedding image-models - Image
Init Options User Defined image-models - Options for initializing UserDefinedImageEmbeddingModel
- Image
Preprocessor image-models - A model-specific image preprocessor that can be shared with CPU worker threads.
- Init
Options User Defined onnx - Options for initializing a user-defined embedding model.
- Init
Options With Length onnx - Model
Info onnx - Data struct about the available models
- Nomic
Bert Model nomic-v2-moe - Nomic
Config nomic-v2-moe - Nomic
V2Moe Text Embedding nomic-v2-moe - Qwen3
Config qwen3-text - Qwen3
Model qwen3-text - Qwen3
Reranker qwen3-text - Qwen3-Reranker (for example
Qwen/Qwen3-Reranker-0.6B): the probability that a document answers a query under an instruction, read as the model’s “yes” against “no” at the last position, as the model card computes it. - Qwen3
Text Embedding qwen3-text - High-level embedding wrapper around
Qwen3Modelthat handles tokenization, batching, mean-pooling, and L2-normalization. - Qwen3VL
Embedding qwen3-textandqwen3-vl - Multimodal embedding wrapper for Qwen3-VL embedding checkpoints.
- Rerank
Init Options User Defined onnx - Options for initializing a user-defined reranking model.
- Rerank
Result onnx - Rerank result.
- Reranker
Model Info onnx - Data struct about the available reranker models
- Sparse
Embedding - Sparse
Text Embedding onnx - Rust representation of the SparseTextEmbedding model
- Text
Embedding onnx - Rust representation of the TextEmbedding model
- Text
Rerank onnx - Tokenizer
Files - User
Defined Bgem3 Model onnx - Struct for “bring your own” BGE-M3 models
- User
Defined Embedding Model onnx - Struct for “bring your own” embedding models
- User
Defined Image Embedding Model image-models - Struct for “bring your own” embedding models
- User
Defined Reranking Model onnx - Struct for “bring your own” reranking models
- User
Defined Sparse Model onnx - Struct for “bring your own” sparse embedding models
Enums§
- Bgem3
Model onnx - Embedding
Model onnx - Error
- Error type returned by fastembed.
- Image
Embedding Model onnx - Onnx
Source onnx - Enum for the source of the onnx file
- Pooling
onnx - Quantization
Mode onnx - Enum for quantization mode.
- Reranker
Model onnx - Sparse
Model onnx
Constants§
- QWEN3_
RERANKER_ DEFAULT_ INSTRUCTION qwen3-text - The instruction the Qwen3-Reranker model card uses when none is given.
Traits§
- Model
Trait onnx
Functions§
Type Aliases§
- Bgem3
Init Options onnx - Options for initializing the Bgem3Embedding model
- Embedding
- Type alias for the embedding vector
- Image
Init Options image-models - Options for initializing the ImageEmbedding model
- Init
Options Deprecated onnx - Rerank
Init Options onnx - Options for initializing the reranking models
- Result
- Type alias for
Resultreturning the fastembedErrortype. - Sparse
Init Options onnx - Options for initializing the SparseTextEmbedding model
- Text
Init Options onnx - Options for initializing the TextEmbedding model