Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(fastembed,qdrant): Better batching defaults #334

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion swiftide-integrations/src/fastembed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ impl From<SparseTextEmbedding> 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
Expand Down Expand Up @@ -60,7 +65,7 @@ pub struct FastEmbed {
default = "Arc::new(TextEmbedding::try_new(Default::default())?.into())"
)]
embedding_model: Arc<EmbeddingModelType>,
#[builder(default)]
#[builder(default = "Some(DEFAULT_BATCH_SIZE)")]
batch_size: Option<usize>,
}

Expand Down
3 changes: 2 additions & 1 deletion swiftide-integrations/src/qdrant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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<usize>,
#[builder(private, default = "Self::default_vectors()")]
pub(crate) vectors: HashMap<EmbeddedField, VectorConfig>,
Expand Down