Expand description
FastEmbed - Fast, light, accurate library built for retrieval embedding generation.
Local ONNX inference, synchronous, no Tokio. Models download once and run offline thereafter.
§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
Qwen3 and Nomic v2 MoE embeddings are available behind the qwen3 and
nomic-v2-moe feature flags (candle backend).
§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;pub use crate::output::OutputKey;pub use crate::output::OutputPrecedence;pub use crate::output::SingleBatchOutput;
Modules§
- output
- Utilities to help with the embeddings output.
- similarity
- Similarity helpers for comparing embeddings.
Structs§
- Base
Init Options - Bgem3
Embedding - Rust representation of the BGE-M3 joint embedding model
- Bgem3
Embedding Output - Output of
Bgem3Embedding: dense, sparse (lexical), and ColBERT (multi-vector) representations from a single pass. - Execution
Provider Dispatch - 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 - Rust representation of the ImageEmbedding model
- Image
Init Options User Defined image-models - Options for initializing UserDefinedImageEmbeddingModel
- Init
Options User Defined - Options for initializing UserDefinedEmbeddingModel
- Init
Options With Length - Model
Info - Data struct about the available models
- Nomic
Config nomic-v2-moe - Nomic
V2Moe Text Embedding nomic-v2-moe - Qwen3
Config qwen3 - Qwen3
Model qwen3 - Qwen3
Text Embedding qwen3 - High-level embedding wrapper around
Qwen3Modelthat handles tokenization, batching, mean-pooling, and L2-normalization. - Qwen3VL
Embedding qwen3 - Multimodal embedding wrapper for Qwen3-VL embedding checkpoints.
- Rerank
Init Options User Defined - Options for initializing UserDefinedRerankerModel
- Rerank
Result - Rerank result.
- Reranker
Model Info - Data struct about the available reranker models
- Sparse
Embedding - Sparse
Text Embedding - Rust representation of the SparseTextEmbedding model
- Text
Embedding - Rust representation of the TextEmbedding model
- Text
Rerank - Tokenizer
Files - User
Defined Bgem3 Model - Struct for “bring your own” BGE-M3 models
- User
Defined Embedding Model - 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 - Struct for “bring your own” reranking models
- User
Defined Sparse Model - Struct for “bring your own” embedding models
Enums§
- Bgem3
Model - Embedding
Model - Image
Embedding Model - Onnx
Source - Enum for the source of the onnx file
- Pooling
- Quantization
Mode - Enum for quantization mode.
- Reranker
Model - Sparse
Model
Traits§
Functions§
Type Aliases§
- Bgem3
Init Options - Options for initializing the Bgem3Embedding model
- Embedding
- Type alias for the embedding vector
- Error
- Type alias for the error type
- Image
Init Options image-models - Options for initializing the ImageEmbedding model
- Init
Options - Options for initializing the TextEmbedding model
- Rerank
Init Options - Options for initializing the reranking models
- Sparse
Init Options - Options for initializing the SparseTextEmbedding model
- Text
Init Options - Options for initializing the TextEmbedding model