Skip to content

Pointers for implementing custom token filtering #13638

Answered by slaren
ahelwer asked this question in Q&A
Discussion options

You must be logged in to vote

There is an interface that you can implement to add custom samplers. See:

llama.cpp/include/llama.h

Lines 1193 to 1209 in 8960efd

// user code can implement the interface below in order to create custom llama_sampler
struct llama_sampler_i {
const char * (*name) (const struct llama_sampler * smpl); // can be NULL
void (*accept)( struct llama_sampler * smpl, llama_token token); // can be NULL
void (*apply) ( struct llama_sampler * smpl, llama_token_data_array * cur_p); // required
void (*reset) ( struct llama_sampler * smpl); // can be NULL
struct llama_sampler * (*clone) (const struct llama_sampler * smpl); // can be NULL if ctx is NULL
void

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ahelwer
Comment options

Answer selected by ahelwer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants