class

Llama::Sampler::TopK

Inherits Llama::Sampler::Base / Reference / Object

Top-K sampler

The Top-K sampler keeps only the K most likely tokens and zeros out the rest. This is a simple but effective way to filter out unlikely tokens.

Example:

sampler = Llama::Sampler::TopK.new(40) # Keep only the top 40 tokens

Constructors

new(k : Int32)

Creates a new Top-K sampler

Parameters:

  • k: The number of top tokens to consider

Raises:

  • Llama::Error if the sampler cannot be created
Source