LumosAI FastEmbed Integration
FastEmbed integration for LumosAI vector storage, providing fast, local embedding generation without external API dependencies.
π Features
- Local Processing: Generate embeddings locally without API calls
- Multiple Models: Support for various pre-trained models (BGE, MiniLM, E5)
- High Performance: Optimized for batch processing with configurable batch sizes
- Multilingual Support: Models supporting 100+ languages
- Easy Integration: Seamless integration with LumosAI vector storage
- Memory Efficient: Lazy loading and configurable caching
- Type Safe: Full Rust type safety with comprehensive error handling
π¦ Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= "0.1.0"
π― Quick Start
Basic Usage
use ;
use EmbeddingModel;
async
Custom Configuration
use ;
async
π€ Available Models
English Models
| Model | Dimensions | Max Length | Best For |
|---|---|---|---|
BGESmallENV15 |
384 | 512 | Fast general purpose |
BGEBaseENV15 |
768 | 512 | Balanced quality/speed |
BGELargeENV15 |
1024 | 512 | High quality |
AllMiniLML6V2 |
384 | 256 | Lightweight, fast |
AllMiniLML12V2 |
384 | 256 | Better than L6 |
Multilingual Models
| Model | Dimensions | Languages | Best For |
|---|---|---|---|
MultilingualE5Small |
384 | 100+ | Multilingual apps |
MultilingualE5Base |
768 | 100+ | High-quality multilingual |
MultilingualE5Large |
1024 | 100+ | Best multilingual quality |
Model Selection Guide
// For fast, general purpose English text
BGESmallENV15
// For balanced performance and quality
BGEBaseENV15
// For highest quality English embeddings
BGELargeENV15
// For multilingual applications
MultilingualE5Small
// For real-time applications
AllMiniLML6V2
π§ Configuration Options
FastEmbedConfig
use FastEmbedConfigBuilder;
let config = new
.max_batch_size // Maximum texts per batch
.show_download_progress // Show model download progress
.num_threads // Number of processing threads
.cache_dir // Model cache directory
.build;
Performance Tuning
- Batch Size: Larger batches are more efficient but use more memory
- Threads: More threads can improve performance on multi-core systems
- Cache Directory: Store models on fast storage (SSD) for better performance
π Performance Benchmarks
Throughput (texts/second)
| Model | Single | Batch (256) | Memory Usage |
|---|---|---|---|
| BGE Small | 50 | 800 | ~500MB |
| BGE Base | 30 | 500 | ~1GB |
| BGE Large | 20 | 300 | ~2GB |
| MiniLM L6 | 80 | 1200 | ~300MB |
Benchmarks on Intel i7-10700K, 32GB RAM
π Multilingual Support
use ;
async
π Vector Search Example
use ;
async
π§ͺ Examples
Run the included examples:
# Basic embedding generation
# Batch processing optimization
# Vector search and similarity
π§ Integration with LumosAI Vector Storage
use ;
use VectorStorage;
// Use with any LumosAI vector storage backend
let embedding_provider = with_model.await?;
let vector_storage = /* your vector storage implementation */;
// The embedding provider implements the EmbeddingModel trait
// and can be used with any LumosAI vector storage backend
π Documentation
π€ Contributing
Contributions are welcome! Please see our Contributing Guide for details.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- FastEmbed for the excellent local embedding library
- Hugging Face for the pre-trained models
- The Rust community for amazing crates and tools