pub struct BatchProcessor { /* private fields */ }Expand description
Represents a batch of texts to be processed.
Implementations§
Source§impl BatchProcessor
impl BatchProcessor
Sourcepub fn builder() -> BatchProcessorBuilder
pub fn builder() -> BatchProcessorBuilder
Creates a batch processor with custom configuration.
Sourcepub fn process_batch(
&self,
model: &mut EmbeddingModel,
texts: &[&str],
) -> Result<Vec<Vec<f32>>>
pub fn process_batch( &self, model: &mut EmbeddingModel, texts: &[&str], ) -> Result<Vec<Vec<f32>>>
Processes a batch of texts to generate embeddings.
This function implements the following pipeline:
- Parallel tokenization of all texts (using rayon)
- True batch model inference (multiple sequences in single pass)
- Parallel post-processing and normalization (handled by model)
§Arguments
model- The embedding model to usetexts- Vector of texts to process
§Returns
Returns a vector of embedding vectors, maintaining the input order.
§Errors
This function will return an error if:
- Any text fails tokenization
- Model inference fails
- Memory allocation fails
Sourcepub fn set_progress_callback<F>(&mut self, callback: F)
pub fn set_progress_callback<F>(&mut self, callback: F)
Sets a progress callback for batch processing.
The callback will be called with (current_index, total_count) during processing.
§Arguments
callback- A function that receives progress updates
Auto Trait Implementations§
impl Freeze for BatchProcessor
impl !RefUnwindSafe for BatchProcessor
impl Send for BatchProcessor
impl Sync for BatchProcessor
impl Unpin for BatchProcessor
impl !UnwindSafe for BatchProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more