pub trait Sampler {
// Required methods
fn next_pair_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<SampleBatch, SamplerError>;
fn next_text_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<TextBatch, SamplerError>;
fn next_triplet_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<TripletBatch, SamplerError>;
// Provided methods
fn next_pair_batch(
&self,
split: SplitLabel,
) -> Result<SampleBatch, SamplerError> { ... }
fn next_text_batch(
&self,
split: SplitLabel,
) -> Result<TextBatch, SamplerError> { ... }
fn next_triplet_batch(
&self,
split: SplitLabel,
) -> Result<TripletBatch, SamplerError> { ... }
fn save_sampler_state(
&self,
_save_to: Option<&Path>,
) -> Result<(), SamplerError> { ... }
}Expand description
Public sampling interface for pair, triplet, and text batch generation.
Required Methods§
Sourcefn next_pair_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<SampleBatch, SamplerError>
fn next_pair_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<SampleBatch, SamplerError>
Returns a batch of pairs with per-call source weights.
Sourcefn next_text_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<TextBatch, SamplerError>
fn next_text_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TextBatch, SamplerError>
Returns a batch of text samples with per-call source weights.
Sourcefn next_triplet_batch_with_weights(
&self,
split: SplitLabel,
weights: &HashMap<SourceId, f32>,
) -> Result<TripletBatch, SamplerError>
fn next_triplet_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TripletBatch, SamplerError>
Returns a batch of triplets with per-call source weights.
Provided Methods§
Sourcefn next_pair_batch(
&self,
split: SplitLabel,
) -> Result<SampleBatch, SamplerError>
fn next_pair_batch( &self, split: SplitLabel, ) -> Result<SampleBatch, SamplerError>
Returns a batch of pairs. Consumes the shared epoch cursor for anchor selection.
Sourcefn next_text_batch(&self, split: SplitLabel) -> Result<TextBatch, SamplerError>
fn next_text_batch(&self, split: SplitLabel) -> Result<TextBatch, SamplerError>
Returns a batch of text samples. Consumes the shared epoch cursor for anchor selection.
Sourcefn next_triplet_batch(
&self,
split: SplitLabel,
) -> Result<TripletBatch, SamplerError>
fn next_triplet_batch( &self, split: SplitLabel, ) -> Result<TripletBatch, SamplerError>
Returns a batch of triplets. Consumes the shared epoch cursor for anchor selection.
Sourcefn save_sampler_state(
&self,
_save_to: Option<&Path>,
) -> Result<(), SamplerError>
fn save_sampler_state( &self, _save_to: Option<&Path>, ) -> Result<(), SamplerError>
Persist sampler and split runtime state for restart-resume.
Default is a no-op, allowing mock/test implementations to skip persistence.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".