From 08c2b14f84da4bd2202203ffea1b483dfdb2c8d1 Mon Sep 17 00:00:00 2001 From: Jhen-Jie Hong Date: Tue, 31 Dec 2024 10:30:22 +0800 Subject: [PATCH] feat: add XTC / DRY sampler params (#65) --- lib/binding.ts | 16 +++++++++++++++- src/LlamaContext.cpp | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/binding.ts b/lib/binding.ts index d8455e5..2f0afe8 100644 --- a/lib/binding.ts +++ b/lib/binding.ts @@ -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 diff --git a/src/LlamaContext.cpp b/src/LlamaContext.cpp index d5316c5..2474a69 100644 --- a/src/LlamaContext.cpp +++ b/src/LlamaContext.cpp @@ -214,6 +214,12 @@ Napi::Value LlamaContext::Completion(const Napi::CallbackInfo &info) { params.sampling.penalty_present = get_option(options, "penalty_present", 0.00f); params.sampling.typ_p = get_option(options, "typical_p", 1.00f); + params.sampling.xtc_threshold = get_option(options, "xtc_threshold", 0.00f); + params.sampling.xtc_probability = get_option(options, "xtc_probability", 0.10f); + params.sampling.dry_multiplier = get_option(options, "dry_multiplier", 1.75f); + params.sampling.dry_base = get_option(options, "dry_base", 2); + params.sampling.dry_allowed_length = get_option(options, "dry_allowed_length", -1); + params.sampling.dry_penalty_last_n = get_option(options, "dry_penalty_last_n", 0); params.sampling.ignore_eos = get_option(options, "ignore_eos", false); params.sampling.grammar = get_option(options, "grammar", ""); params.n_keep = get_option(options, "n_keep", 0);