pub struct LengthBasedExampleSelector<E> { /* private fields */ }Expand description
Greedy: include each example in order until adding the next would
exceed the configured max_tokens budget. The input itself is
counted against the budget so callers know how much head-room is
left for completion.
Implementations§
Source§impl<E> LengthBasedExampleSelector<E>
impl<E> LengthBasedExampleSelector<E>
Sourcepub fn new<F>(
max_tokens: usize,
tokenizer: Arc<dyn Tokenizer>,
render: F,
) -> Self
pub fn new<F>( max_tokens: usize, tokenizer: Arc<dyn Tokenizer>, render: F, ) -> Self
Build a length-budgeted selector.
render converts an example to the text that will be substituted
into the prompt — used by the tokenizer to size each example.
Sourcepub fn with_render<F>(self, render: F) -> Self
pub fn with_render<F>(self, render: F) -> Self
Replace the render function (e.g. when the prompt template changes).
Sourcepub fn with_tokenizer(self, tokenizer: Arc<dyn Tokenizer>) -> Self
pub fn with_tokenizer(self, tokenizer: Arc<dyn Tokenizer>) -> Self
Replace the tokenizer (e.g. swap CharTokenizer for tiktoken).
Trait Implementations§
Source§impl<E: Clone> Clone for LengthBasedExampleSelector<E>
impl<E: Clone> Clone for LengthBasedExampleSelector<E>
Source§fn clone(&self) -> LengthBasedExampleSelector<E>
fn clone(&self) -> LengthBasedExampleSelector<E>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E> Debug for LengthBasedExampleSelector<E>
impl<E> Debug for LengthBasedExampleSelector<E>
Source§impl<E> ExampleSelector<E> for LengthBasedExampleSelector<E>
impl<E> ExampleSelector<E> for LengthBasedExampleSelector<E>
Auto Trait Implementations§
impl<E> Freeze for LengthBasedExampleSelector<E>
impl<E> !RefUnwindSafe for LengthBasedExampleSelector<E>
impl<E> Send for LengthBasedExampleSelector<E>
impl<E> Sync for LengthBasedExampleSelector<E>
impl<E> Unpin for LengthBasedExampleSelector<E>
impl<E> UnsafeUnpin for LengthBasedExampleSelector<E>
impl<E> !UnwindSafe for LengthBasedExampleSelector<E>
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