@@ -63,7 +63,7 @@ impl LlamaSampler {
6363 }
6464
6565 /// Resets the internal state of the sampler.
66- ///
66+ ///
6767 /// This can be useful when you want to start fresh with a sampler without creating a new instance.
6868 pub fn reset ( & mut self ) {
6969 unsafe {
@@ -72,15 +72,15 @@ impl LlamaSampler {
7272 }
7373
7474 /// Gets the random seed used by this sampler.
75- ///
75+ ///
7676 /// Returns:
7777 /// - For random samplers (dist, mirostat, mirostat_v2): returns their current seed
7878 /// - For sampler chains: returns the first non-default seed found in reverse order
7979 /// - For all other samplers: returns 0xFFFFFFFF
8080 #[ must_use]
8181 pub fn get_seed ( & self ) -> u32 {
8282 unsafe { llama_cpp_sys_2:: llama_sampler_get_seed ( self . sampler ) }
83- }
83+ }
8484
8585 /// Combines a list of samplers into a single sampler that applies each component sampler one
8686 /// after another.
@@ -213,11 +213,11 @@ impl LlamaSampler {
213213 Self { sampler }
214214 }
215215
216- /// Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
216+ /// Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
217217 /// <https://arxiv.org/pdf/2411.07641>
218218 ///
219219 /// This method filters logits by selecting only those within *n* standard deviations of the mean.
220- ///
220+ ///
221221 /// # Parameters
222222 /// - `n`: Number of standard deviations from the mean to include in sampling
223223 ///
@@ -232,7 +232,7 @@ impl LlamaSampler {
232232 ///
233233 /// let mut data_array = LlamaTokenDataArray::new(vec![
234234 /// LlamaTokenData::new(LlamaToken(0), 0.0, 0.0),
235- /// LlamaTokenData::new(LlamaToken(1), 1.0, 0.0),
235+ /// LlamaTokenData::new(LlamaToken(1), 1.0, 0.0),
236236 /// LlamaTokenData::new(LlamaToken(2), 2.0, 0.0),
237237 /// ], false);
238238 ///
@@ -314,17 +314,15 @@ impl LlamaSampler {
314314 ) -> Option < Self > {
315315 let grammar_str = CString :: new ( grammar_str) . unwrap ( ) ;
316316 let grammar_root = CString :: new ( grammar_root) . unwrap ( ) ;
317-
317+
318318 let trigger_word_cstrings: Vec < CString > = trigger_words
319319 . into_iter ( )
320320 . map ( |word| CString :: new ( word. as_ref ( ) ) . unwrap ( ) )
321321 . collect ( ) ;
322-
323- let mut trigger_word_ptrs: Vec < * const c_char > = trigger_word_cstrings
324- . iter ( )
325- . map ( |cs| cs. as_ptr ( ) )
326- . collect ( ) ;
327-
322+
323+ let mut trigger_word_ptrs: Vec < * const c_char > =
324+ trigger_word_cstrings. iter ( ) . map ( |cs| cs. as_ptr ( ) ) . collect ( ) ;
325+
328326 let sampler = unsafe {
329327 llama_cpp_sys_2:: llama_sampler_init_grammar_lazy (
330328 model. vocab_ptr ( ) ,
@@ -504,20 +502,14 @@ impl LlamaSampler {
504502 /// ```
505503 #[ must_use]
506504 pub fn logit_bias ( n_vocab : i32 , biases : & [ LlamaLogitBias ] ) -> Self {
507-
508505 let data = biases. as_ptr ( ) . cast :: < llama_cpp_sys_2:: llama_logit_bias > ( ) ;
509-
506+
510507 let sampler = unsafe {
511- llama_cpp_sys_2:: llama_sampler_init_logit_bias (
512- n_vocab,
513- biases. len ( ) as i32 ,
514- data,
515- )
508+ llama_cpp_sys_2:: llama_sampler_init_logit_bias ( n_vocab, biases. len ( ) as i32 , data)
516509 } ;
517-
510+
518511 Self { sampler }
519512 }
520-
521513}
522514
523515impl Drop for LlamaSampler {
0 commit comments