Skip to main content

SamplerOrder

Struct SamplerOrder 

Source
pub struct SamplerOrder { /* private fields */ }
Expand description

A validated sampler chain: the steps ferrox will run, in the order it will run them.

Fixed-capacity and Copy because crate::sampling::SamplingParams is cloned per request and read per token; a Vec here would be an allocation on that path for at most SamplerName::ALL.len() entries.

Implementations§

Source§

impl SamplerOrder

Source

pub fn steps(&self) -> &[ChainStep]

The steps, in order.

Source

pub fn has_penalties(&self) -> bool

Whether the penalties are part of this chain. false means the caller left penalties out, which llama.cpp reads as “do not penalise”, so ferrox must not penalise either.

Source

pub fn implemented_names() -> Vec<&'static str>

The canonical spellings of every sampler this engine implements, derived from the one table rather than restated.

Source

pub fn from_names<I, S>(names: I) -> Result<Self, SamplerOrderError>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Parse a chain from already-split names.

Each name is trimmed and lowercased first: a spelling is not a semantic, so Top_K cannot mean anything but top_k and refusing it would be a false refusal.

Four things are refused, all BY NAME:

  • a name llama.cpp does not define either;
  • a real llama.cpp sampler ferrox does not implement;
  • the same sampler twice, which llama.cpp tolerates and which here would silently mean “run it once” for the idempotent filters and “square it” for temperature;
  • penalties anywhere but first – see SamplerOrderError::PenaltiesNotFirst;
  • a chain with no temperature – see SamplerOrderError::TemperatureMissing.

Trait Implementations§

Source§

impl Clone for SamplerOrder

Source§

fn clone(&self) -> SamplerOrder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SamplerOrder

Source§

impl Debug for SamplerOrder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SamplerOrder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for SamplerOrder

Round-trips through FromStr, so the CLI can print the default it applied and have that string mean the same chain.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SamplerOrder

Source§

impl FromStr for SamplerOrder

;-separated, exactly as llama.cpp’s --samplers takes it.

Source§

type Err = SamplerOrderError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for SamplerOrder

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SamplerOrder

Equality and hashing are over the LIVE steps only. The backing array is fixed-capacity, so the slots past len hold filler that two equal chains need not agree about – and the response cache keys on this, where a spurious inequality would just miss and a spurious equality would serve one caller’s answer to another.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.