Skip to main content

Crate fastembed

Crate fastembed 

Source
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

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: 4

Re-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§

BaseInitOptions
Bgem3Embedding
Rust representation of the BGE-M3 joint embedding model
Bgem3EmbeddingOutput
Output of Bgem3Embedding: dense, sparse (lexical), and ColBERT (multi-vector) representations from a single pass.
ExecutionProviderDispatch
Dynamic execution provider container, used to provide a list of multiple types of execution providers when configuring execution providers for a SessionBuilder or EnvironmentBuilder.
ImageEmbeddingimage-models
Rust representation of the ImageEmbedding model
ImageInitOptionsUserDefinedimage-models
Options for initializing UserDefinedImageEmbeddingModel
InitOptionsUserDefined
Options for initializing UserDefinedEmbeddingModel
InitOptionsWithLength
ModelInfo
Data struct about the available models
NomicConfignomic-v2-moe
NomicV2MoeTextEmbeddingnomic-v2-moe
Qwen3Configqwen3
Qwen3Modelqwen3
Qwen3TextEmbeddingqwen3
High-level embedding wrapper around Qwen3Model that handles tokenization, batching, mean-pooling, and L2-normalization.
Qwen3VLEmbeddingqwen3
Multimodal embedding wrapper for Qwen3-VL embedding checkpoints.
RerankInitOptionsUserDefined
Options for initializing UserDefinedRerankerModel
RerankResult
Rerank result.
RerankerModelInfo
Data struct about the available reranker models
SparseEmbedding
SparseTextEmbedding
Rust representation of the SparseTextEmbedding model
TextEmbedding
Rust representation of the TextEmbedding model
TextRerank
TokenizerFiles
UserDefinedBgem3Model
Struct for “bring your own” BGE-M3 models
UserDefinedEmbeddingModel
Struct for “bring your own” embedding models
UserDefinedImageEmbeddingModelimage-models
Struct for “bring your own” embedding models
UserDefinedRerankingModel
Struct for “bring your own” reranking models
UserDefinedSparseModel
Struct for “bring your own” embedding models

Enums§

Bgem3Model
EmbeddingModel
ImageEmbeddingModel
OnnxSource
Enum for the source of the onnx file
Pooling
QuantizationMode
Enum for quantization mode.
RerankerModel
SparseModel

Traits§

ModelTrait

Functions§

get_cache_dir

Type Aliases§

Bgem3InitOptions
Options for initializing the Bgem3Embedding model
Embedding
Type alias for the embedding vector
Error
Type alias for the error type
ImageInitOptionsimage-models
Options for initializing the ImageEmbedding model
InitOptions
Options for initializing the TextEmbedding model
RerankInitOptions
Options for initializing the reranking models
SparseInitOptions
Options for initializing the SparseTextEmbedding model
TextInitOptions
Options for initializing the TextEmbedding model