From bd3a4fa05423c0873415a65c272c23e145e32e25 Mon Sep 17 00:00:00 2001 From: Timon Vonk Date: Wed, 25 Sep 2024 09:21:02 +0200 Subject: [PATCH] chore(fastembed,qdrant): Better batching defaults --- swiftide-integrations/src/fastembed/mod.rs | 7 ++++++- swiftide-integrations/src/qdrant/mod.rs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/swiftide-integrations/src/fastembed/mod.rs b/swiftide-integrations/src/fastembed/mod.rs index 1256f87d..8200227a 100644 --- a/swiftide-integrations/src/fastembed/mod.rs +++ b/swiftide-integrations/src/fastembed/mod.rs @@ -29,6 +29,11 @@ impl From for EmbeddingModelType { } } +/// Default batch size for embedding +/// +/// Matches the default batch size in [`fastembed`](https://docs.rs/fastembed) +const DEFAULT_BATCH_SIZE: usize = 256; + /// A wrapper around the `FastEmbed` library for text embedding. /// /// Supports a variety of fast text embedding models. The default is the `Flag Embedding` model @@ -60,7 +65,7 @@ pub struct FastEmbed { default = "Arc::new(TextEmbedding::try_new(Default::default())?.into())" )] embedding_model: Arc, - #[builder(default)] + #[builder(default = "Some(DEFAULT_BATCH_SIZE)")] batch_size: Option, } diff --git a/swiftide-integrations/src/qdrant/mod.rs b/swiftide-integrations/src/qdrant/mod.rs index 26a393cb..0ba0b695 100644 --- a/swiftide-integrations/src/qdrant/mod.rs +++ b/swiftide-integrations/src/qdrant/mod.rs @@ -19,6 +19,7 @@ use swiftide_core::indexing::{EmbeddedField, Node}; const DEFAULT_COLLECTION_NAME: &str = "swiftide"; const DEFAULT_QDRANT_URL: &str = "http://localhost:6334"; +const DEFAULT_BATCH_SIZE: usize = 50; /// A struct representing a Qdrant client with configuration options. /// @@ -50,7 +51,7 @@ pub struct Qdrant { /// The default distance of the vectors to be stored in the collection vector_distance: Distance, /// The batch size for operations. Optional. - #[builder(default)] + #[builder(default = "Some(DEFAULT_BATCH_SIZE)")] batch_size: Option, #[builder(private, default = "Self::default_vectors()")] pub(crate) vectors: HashMap,