Expand description
FastEmbed - Fast, light, accurate library built for retrieval embedding generation.
The library provides the TextEmbedding struct to interface with text embedding models.
§Instantiating TextEmbedding
use fastembed::{TextEmbedding, InitOptions, EmbeddingModel};
// With default InitOptions
let model = TextEmbedding::try_new(Default::default())?;
// List all supported models
dbg!(TextEmbedding::list_supported_models());
// With custom InitOptions
let model = TextEmbedding::try_new(InitOptions {
model_name: EmbeddingModel::BGEBaseENV15,
show_download_progress: false,
..Default::default()
})?;
Find more info about the available options in the InitOptions 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 MIT"
];
// Generate embeddings with the default batch size, 256
let embeddings = model.embed(documents, None)?;
println!("Embeddings length: {}", embeddings.len()); // -> Embeddings length: 4
Structs§
- Options for initializing the TextEmbedding model
- Options for initializing UserDefinedEmbeddingModel
- Data struct about the available models
- Options for initializing the TextEmbedding model
- Rerank result.
- Data struct about the available reanker models
- Rust representation of the TextEmbedding model
- Struct for “bring your own” embedding models
Enums§
- Execution provider container. See the ONNX Runtime docs for more info on execution providers. Execution providers are actually registered via the functions
crate::SessionBuilder
(per-session) orEnvironmentBuilder
(default for all sessions in an environment).
Functions§
- Public function to read a file to bytes. To be used when loading local model files.
Type Aliases§
- Type alias for the embedding vector