Skip to content

Commit

Permalink
feat: add XTC / DRY sampler params (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 authored Dec 31, 2024
1 parent 5cfa9d6 commit 08c2b14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ export type LlamaCompletionOptions = {
temperature?: number
top_k?: number
top_p?: number
repetition_penalty?: number
min_p?: number
mirostat?: number
mirostat_tau?: number
mirostat_eta?: number
penalty_last_n?: number
penalty_repeat?: number
penalty_freq?: number
penalty_present?: number
typ_p?: number
xtc_threshold?: number
xtc_probability?: number
dry_multiplier?: number
dry_base?: number
dry_allowed_length?: number
dry_penalty_last_n?: number
n_predict?: number
max_length?: number
max_tokens?: number
Expand Down
6 changes: 6 additions & 0 deletions src/LlamaContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ Napi::Value LlamaContext::Completion(const Napi::CallbackInfo &info) {
params.sampling.penalty_present =
get_option<float>(options, "penalty_present", 0.00f);
params.sampling.typ_p = get_option<float>(options, "typical_p", 1.00f);
params.sampling.xtc_threshold = get_option<float>(options, "xtc_threshold", 0.00f);
params.sampling.xtc_probability = get_option<float>(options, "xtc_probability", 0.10f);
params.sampling.dry_multiplier = get_option<float>(options, "dry_multiplier", 1.75f);
params.sampling.dry_base = get_option<float>(options, "dry_base", 2);
params.sampling.dry_allowed_length = get_option<float>(options, "dry_allowed_length", -1);
params.sampling.dry_penalty_last_n = get_option<float>(options, "dry_penalty_last_n", 0);
params.sampling.ignore_eos = get_option<bool>(options, "ignore_eos", false);
params.sampling.grammar = get_option<std::string>(options, "grammar", "");
params.n_keep = get_option<int32_t>(options, "n_keep", 0);
Expand Down

0 comments on commit 08c2b14

Please sign in to comment.