class Llama::Sampler::TopK

Overview

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

Defined in:

llama/sampler/top_k.cr

Constructors

Instance methods inherited from class Llama::Sampler::Base

to_unsafe : Pointer(Llama::LibLlama::LlamaSampler) to_unsafe

Constructor methods inherited from class Llama::Sampler::Base

new(handle : Pointer(LibLlama::LlamaSampler)) new

Constructor Detail

def self.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

[View source]