Skip to content

Commit

Permalink
deprecated the sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusDunn committed Feb 27, 2024
1 parent 3c27f80 commit a2adc4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llama-cpp-2/src/context/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ use llama_cpp_sys_2::llama_context;

/// struct to hold params for sampling
#[derive(Debug)]
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
pub struct Sampler<'grammar> {
token_data_array: LlamaTokenDataArray,
grammar: Option<&'grammar mut LlamaGrammar>,
temperature: Option<f32>,
}

impl<'grammar> Sampler<'grammar> {
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
fn sample(self, llama_context: &mut LlamaContext) -> LlamaToken {
match self {
Sampler {
Expand Down Expand Up @@ -58,6 +60,7 @@ impl<'grammar> Sampler<'grammar> {

/// Create a new sampler.
#[must_use]
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
pub fn new(llama_token_data_array: LlamaTokenDataArray) -> Self {
Self {
token_data_array: llama_token_data_array,
Expand All @@ -68,6 +71,7 @@ impl<'grammar> Sampler<'grammar> {

/// Set the grammar for sampling.
#[must_use]
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
pub fn with_grammar(mut self, grammar: &'grammar mut LlamaGrammar) -> Self {
self.grammar = Some(grammar);
self
Expand All @@ -87,6 +91,7 @@ impl<'grammar> Sampler<'grammar> {
/// .with_temperature(0.5);
/// ```
#[must_use]
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
pub fn with_temperature(mut self, temperature: f32) -> Self {
if temperature == 0.0 {
return self;
Expand All @@ -102,6 +107,7 @@ impl LlamaContext<'_> {
/// # Panics
///
/// - sampler contains no tokens
#[deprecated(since = "0.1.32", note = "this does not scale well with many params and does not allow for changing of orders.")]
pub fn sample(&mut self, sampler: Sampler) -> LlamaToken {
sampler.sample(self)
}
Expand Down

0 comments on commit a2adc4e

Please sign in to comment.