chore: slight refactor of aphrodite samplers

This commit is contained in:
AlpinDale 2024-09-13 10:34:06 +00:00
parent 7c383e3218
commit efd477da04
2 changed files with 52 additions and 35 deletions

View File

@ -1189,7 +1189,7 @@
<input class="neo-range-slider" type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
<input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">
</div>
<div data-tg-type="ooba,mancer" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<small>
<span data-i18n="Epsilon Cutoff">Epsilon Cutoff</span>
<div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Epsilon cutoff sets a probability floor below which tokens are excluded from being sampled" title="Epsilon cutoff sets a probability floor below which tokens are excluded from being sampled.&#13;In units of 1e-4; a reasonable value is 3.&#13;Set to 0 to disable."></div>
@ -1197,7 +1197,7 @@
<input class="neo-range-slider" type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">
<input class="neo-range-input" type="number" min="0" max="9" step="0.01" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">
</div>
<div data-tg-type="ooba,mancer" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<small>
<span data-i18n="Eta Cutoff">Eta Cutoff</span>
<div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Eta_Cutoff_desc" title="Eta cutoff is the main parameter of the special Eta Sampling technique.&#13;In units of 1e-4; a reasonable value is 3.&#13;Set to 0 to disable.&#13;See the paper Truncation Sampling as Language Model Desmoothing by Hewitt et al. (2022) for details."></div>
@ -1250,7 +1250,7 @@
<input class="neo-range-slider" type="range" id="skew_textgenerationwebui" name="volume" min="-5" max="5" step="0.01" />
<input class="neo-range-input" type="number" min="-5" max="5" step="0.01" data-for="skew_textgenerationwebui" id="skew_counter_textgenerationwebui">
</div>
<div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai, aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
<small data-i18n="Min Length">Min Length</small>
<input class="neo-range-slider" type="range" id="min_length_textgenerationwebui" name="volume" min="0" max="2000" step="1" />
<input class="neo-range-input" type="number" min="0" max="2000" step="1" data-for="min_length_textgenerationwebui" id="min_length_counter_textgenerationwebui">
@ -1339,7 +1339,7 @@
</div>
</div>
</div>
<div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp, aphrodite" id="dynatemp_block_ooba" class="wide100p">
<div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp" id="dynatemp_block_ooba" class="wide100p">
<h4 class="wide100p textAlignCenter">
<div class="flex-container alignitemscenter justifyCenter">
<div class="checkbox_label" for="dynatemp_textgenerationwebui">
@ -1367,7 +1367,7 @@
</div>
</div>
</div>
<div data-tg-type="ooba,aphrodite,infermaticai,koboldcpp,llamacpp,mancer,ollama,tabby" id="mirostat_block_ooba" class="wide100p">
<div data-tg-type="ooba,infermaticai,koboldcpp,llamacpp,mancer,ollama,tabby" id="mirostat_block_ooba" class="wide100p">
<h4 class="wide100p textAlignCenter">
<label data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat</label>
<div class=" fa-solid fa-circle-info opacity50p " data-i18n="[title]Mirostat_desc" title="Mirostat is a thermostat for output perplexity.&#13;Mirostat matches the output perplexity to that of the input, thus avoiding the repetition trap&#13;(where, as the autoregressive inference produces text, the perplexity of the output tends toward zero)&#13;and the confusion trap (where the perplexity diverges).&#13;For details, see the paper Mirostat: A Neural Text Decoding Algorithm that Directly Controls Perplexity by Basu et al. (2020).&#13;Mode chooses the Mirostat version. 0=disable, 1=Mirostat 1.0 (llama.cpp only), 2=Mirostat 2.0."></div>
@ -1396,7 +1396,7 @@
</div>
</div>
</div>
<div data-tg-type="ooba, vllm" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">
<div data-tg-type="ooba, vllm, aphrodite" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">
<h4 class="wide100p textAlignCenter">
<label>
<span data-i18n="Beam search">Beam Search</span>
@ -1537,18 +1537,7 @@
</div>
</div>
</div>
<div id="json_schema_block" data-tg-type="tabby, llamacpp" class="wide100p">
<hr class="wide100p">
<h4 class="wide100p textAlignCenter"><span data-i18n="JSON Schema">JSON Schema</span>
<a href="https://json-schema.org/learn/getting-started-step-by-step" target="_blank">
<small>
<div class="fa-solid fa-circle-question note-link-span"></div>
</small>
</a>
</h4>
<textarea id="tabby_json_schema" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired JSON schema" placeholder="Type in the desired JSON schema"></textarea>
</div>
<div id="grammar_block_ooba" class="wide100p">
<div id="grammar_block_ooba" data-tg-type="ooba,aphrodite" class="wide100p">
<hr class="wide100p">
<h4 class="wide100p textAlignCenter">
<label>
@ -1563,6 +1552,17 @@
</h4>
<textarea id="grammar_string_textgenerationwebui" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired custom grammar" placeholder="Type in the desired custom grammar"></textarea>
</div>
<div id="json_schema_block" data-tg-type="tabby, llamacpp, aphrodite" class="wide100p">
<hr class="wide100p">
<h4 class="wide100p textAlignCenter"><span data-i18n="JSON Schema">JSON Schema</span>
<a href="https://json-schema.org/learn/getting-started-step-by-step" target="_blank">
<small>
<div class="fa-solid fa-circle-question note-link-span"></div>
</small>
</a>
</h4>
<textarea id="tabby_json_schema" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired JSON schema" placeholder="Type in the desired JSON schema"></textarea>
</div>
<div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" class="range-block flexFlowColumn wide100p">
<hr class="wide100p">
<div class="range-block-title">
@ -2425,7 +2425,7 @@
<div data-tg-type="openrouter" class="menu_button menu_button_icon openrouter_authorize" title="Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai" data-i18n="Authorize;[title]Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai">Authorize</div>
<div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
</div>
<label data-tg-type="ooba,aphrodite" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
<label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
<input type="checkbox" id="legacy_api_textgenerationwebui" />
<span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>
</label>

View File

@ -123,6 +123,7 @@ const settings = {
rep_pen_slope: 1,
no_repeat_ngram_size: 0,
penalty_alpha: 0,
use_beam_search: false,
num_beams: 1,
length_penalty: 1,
min_length: 0,
@ -162,14 +163,9 @@ const settings = {
banned_tokens: '',
sampler_priority: OOBA_DEFAULT_ORDER,
samplers: LLAMACPP_DEFAULT_ORDER,
//n_aphrodite: 1,
//best_of_aphrodite: 1,
ignore_eos_token: false,
spaces_between_special_tokens: true,
speculative_ngram: false,
//logits_processors_aphrodite: [],
//log_probs_aphrodite: 0,
//prompt_log_probs_aphrodite: 0,
type: textgen_types.OOBA,
mancer_model: 'mytholite',
togetherai_model: 'Gryphe/MythoMax-L2-13b',
@ -191,6 +187,8 @@ const settings = {
openrouter_allow_fallbacks: true,
xtc_threshold: 0.1,
xtc_probability: 0,
include_stop_str_in_output: false,
guided_regex: '',
};
export let textgenerationwebui_banned_in_macros = [];
@ -250,14 +248,9 @@ export const setting_names = [
'json_schema',
'banned_tokens',
'legacy_api',
//'n_aphrodite',
//'best_of_aphrodite',
'ignore_eos_token',
'spaces_between_special_tokens',
'speculative_ngram',
//'logits_processors_aphrodite',
//'log_probs_aphrodite',
//'prompt_log_probs_aphrodite'
'sampler_order',
'sampler_priority',
'samplers',
@ -268,6 +261,8 @@ export const setting_names = [
'openrouter_allow_fallbacks',
'xtc_threshold',
'xtc_probability',
'include_stop_str_in_output',
'guided_regex',
];
const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba');
@ -1208,13 +1203,35 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
};
const aphroditeParams = {
'n': canMultiSwipe ? settings.n : 1,
'best_of': canMultiSwipe ? settings.n : 1,
'frequency_penalty': settings.freq_pen,
'presence_penalty': settings.presence_pen,
'repetition_penalty': settings.rep_pen,
'seed': settings.seed,
'stop': settings.stopping_strings,
'temperature': settings.temp,
'temperature_last': settings.temperature_last,
'top_p': settings.top_p,
'top_k': settings.top_k,
'top_a': settings.top_a,
'min_p': settings.min_p,
'tfs': settings.tfs,
'eta_cutoff': settings.eta_cutoff,
'epsilon_cutoff': settings.epsilon_cutoff,
'typical_p': settings.typical_p,
'smoothing_factor': settings.smoothing_factor,
'smoothing_curve': settings.smoothing_curve,
'use_beam_search': settings.use_beam_search,
'length_penalty': settings.length_penalty,
'early_stopping': settings.early_stopping,
'ignore_eos': settings.ignore_eos_token,
'min_tokens': settings.min_length,
'skip_special_tokens': settings.skip_special_tokens,
'include_stop_str_in_output': settings.include_stop_str_in_output,
'spaces_between_special_tokens': settings.spaces_between_special_tokens,
'grammar': settings.grammar_string,
//'logits_processors': settings.logits_processors_aphrodite,
//'logprobs': settings.log_probs_aphrodite,
//'prompt_logprobs': settings.prompt_log_probs_aphrodite,
'guided_grammar': settings.grammar_string,
'guided_json': settings.json_schema,
};
if (settings.type === OPENROUTER) {
@ -1254,7 +1271,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
break;
case APHRODITE:
params = Object.assign(params, aphroditeParams);
params = Object.assign(aphroditeParams);
break;
default: