Llama::SamplerChain
SamplerChain: manages a chain of samplers, but is not itself a Sampler::Base. Ownership and lifecycle are managed internally.
Constructors
Instance methods
accept(token : Int32)
Accepts a token, updating the internal state of the samplers
Parameters:
- token: The token to accept
add(sampler : Sampler::Base)
Adds a sampler to the chain
Parameters:
- sampler: The sampler to add to the chain
remove(index : Int)
Removes a sampler from the chain at the given index. Returns the original Sampler::Base instance with ownership restored.
reset
Resets the internal state of the sampler chain. Useful when reusing the same chain for multiple independent generations.
Samples a token using the sampler chain
Parameters:
- ctx: The context to sample from
- idx: The index of the logits to sample from (-1 for the last token)
Returns:
- The sampled token