Struct chat_flame_backend::llm::token_generator::TokenGenerator
source · pub struct TokenGenerator { /* private fields */ }
Expand description
A token generator that generates tokens based on provided parameters, model processor, and sampler.
This struct implements the TokenGeneratorTrait
and provides functionality to generate tokens
for text generation tasks.
Implementations§
source§impl TokenGenerator
impl TokenGenerator
sourcepub fn new(
stop_tokens: HashSet<u32>,
parameter: GenerateParameter,
model: Box<dyn ModelProcessor>,
sampler: Box<dyn Sampler>
) -> Self
pub fn new( stop_tokens: HashSet<u32>, parameter: GenerateParameter, model: Box<dyn ModelProcessor>, sampler: Box<dyn Sampler> ) -> Self
Creates a new TokenGenerator
with the specified parameters.
Arguments
stop_tokens
- A set of token IDs that signal the end of token generation.parameter
- The parameters to use for token generation.model
- A model processor to generate logits.sampler
- A sampler to sample tokens from logits.
Returns
A new instance of TokenGenerator
.
Trait Implementations§
source§impl TokenGeneratorTrait for TokenGenerator
impl TokenGeneratorTrait for TokenGenerator
impl Send for TokenGenerator
Auto Trait Implementations§
impl !RefUnwindSafe for TokenGenerator
impl !Sync for TokenGenerator
impl Unpin for TokenGenerator
impl !UnwindSafe for TokenGenerator
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