Crate lumosai_vector_memory

Source
Expand description

§Lumos Vector Memory Storage

High-performance in-memory vector storage implementation for Lumos. This implementation provides fast vector operations with support for multiple similarity metrics and complex filtering.

§Features

  • High Performance: Optimized for speed with minimal memory overhead
  • Multiple Metrics: Support for cosine, euclidean, and dot product similarity
  • Advanced Filtering: Complex filter conditions with AND/OR/NOT logic
  • Thread Safe: Full async support with efficient locking
  • Memory Efficient: Configurable capacity and memory management

§Example

use lumosai_vector_memory::MemoryVectorStorage;
use lumosai_vector_core::prelude::*;

#[tokio::main]
async fn main() -> lumosai_vector_core::Result<()> {
    // Create storage with initial capacity
    let storage = MemoryVectorStorage::with_capacity(1000).await?;

    // Create an index
    let config = IndexConfig::new("documents", 384)
        .with_metric(SimilarityMetric::Cosine);
    storage.create_index(config).await?;

    // Insert documents
    let docs = vec![
        Document::new("doc1", "Hello world")
            .with_embedding(vec![0.1; 384])  // 384-dimensional vector
            .with_metadata("type", "greeting"),
    ];
    storage.upsert_documents("documents", docs).await?;

    // Search for similar documents
    let request = SearchRequest::new("documents", vec![0.1; 384])
        .with_top_k(5)
        .with_include_metadata(true);

    let response = storage.search(request).await?;
    println!("Found {} results", response.results.len());

    Ok(())
}

Structs§

MemoryConfig
Memory storage configuration
MemoryIndex
In-memory vector index
MemoryVectorStorage
High-performance in-memory vector storage

Type Aliases§

MemoryVectorStore