pub struct BatchProcessor { /* private fields */ }Expand description
Batch processor for preparing text inputs for embedding models.
Implementations§
Source§impl BatchProcessor
impl BatchProcessor
Sourcepub fn new(
tokenizer: Tokenizer,
model: EmbeddingModel,
max_batch_size: usize,
) -> Self
pub fn new( tokenizer: Tokenizer, model: EmbeddingModel, max_batch_size: usize, ) -> Self
Create a new batch processor.
Sourcepub fn max_batch_size(&self) -> usize
pub fn max_batch_size(&self) -> usize
Get the maximum batch size.
Sourcepub fn prepare_texts(&self, texts: &[String], is_query: bool) -> Vec<String>
pub fn prepare_texts(&self, texts: &[String], is_query: bool) -> Vec<String>
Prepare texts for embedding, optionally applying model-specific prefixes.
Sourcepub fn tokenize_batch(&self, texts: &[String]) -> Result<PreparedBatch>
pub fn tokenize_batch(&self, texts: &[String]) -> Result<PreparedBatch>
Tokenize a batch of texts and prepare flat i64 arrays for ORT inference.
Sourcepub fn split_into_batches<'a>(&self, texts: &'a [String]) -> Vec<&'a [String]>
pub fn split_into_batches<'a>(&self, texts: &'a [String]) -> Vec<&'a [String]>
Split texts into batches of maximum size.
Auto Trait Implementations§
impl !Freeze for BatchProcessor
impl RefUnwindSafe for BatchProcessor
impl Send for BatchProcessor
impl Sync for BatchProcessor
impl Unpin for BatchProcessor
impl UnsafeUnpin 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