Struct candle_sampling::logits_processor::LogitsProcessor
source · pub struct LogitsProcessor { /* private fields */ }
Expand description
LogitsProcessor for sampling.
Implementations§
source§impl LogitsProcessor
impl LogitsProcessor
pub fn new( seed: u64, temperature: Option<f64>, sampling_method: SamplingMethod, top_n_logprobs: usize, tokenizer: Tokenizer, repeat_penalty: Option<f32>, presence_penalty: Option<f32>, logits_bias: Option<HashMap<u32, f32>> ) -> Self
sourcepub fn sample(
&mut self,
logits: &Tensor,
penalty_ctxt: Option<&[u32]>
) -> Result<Logprobs>
pub fn sample( &mut self, logits: &Tensor, penalty_ctxt: Option<&[u32]> ) -> Result<Logprobs>
Sample the provided tokens.
If the temperature is None
, argmax sampling is used. Otherwise, the selected sampling is used.
With top-p
sampling, if the top-p
value is <= 0.0
or >= 1.0
, multinomial sampling is used.
If repeat_penalty.is_some()
or presence_penalty.is_some()
, then penalty_ctxt
must be provided.
Auto Trait Implementations§
impl RefUnwindSafe for LogitsProcessor
impl Send for LogitsProcessor
impl Sync for LogitsProcessor
impl Unpin for LogitsProcessor
impl UnwindSafe for LogitsProcessor
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