chore: slight refactor of aphrodite samplers

efd477da04a3c916124eeaacd78a74a6febdf0f1

AlpinDale <alpindale@gmail.com>

2 files changed, +52 -35Ignore whitespace
public/index.html+19 -19
@@ -1189,7 +1189,7 @@
11891189 <input class="neo-range-slider" type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
11901190 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">
11911191 </div>
11921192 <div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
11931193 <small>
11941194 <span data-i18n="Epsilon Cutoff">Epsilon Cutoff</span>
11951195 <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 @@
11971197 <input class="neo-range-slider" type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">
11981198 <input class="neo-range-input" type="number" min="0" max="9" step="0.01" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">
11991199 </div>
12001200 <div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12011201 <small>
12021202 <span data-i18n="Eta Cutoff">Eta Cutoff</span>
12031203 <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 @@
12501250 <input class="neo-range-slider" type="range" id="skew_textgenerationwebui" name="volume" min="-5" max="5" step="0.01" />
12511251 <input class="neo-range-input" type="number" min="-5" max="5" step="0.01" data-for="skew_textgenerationwebui" id="skew_counter_textgenerationwebui">
12521252 </div>
12531253 <div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai, aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12541254 <small data-i18n="Min Length">Min Length</small>
12551255 <input class="neo-range-slider" type="range" id="min_length_textgenerationwebui" name="volume" min="0" max="2000" step="1" />
12561256 <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 @@
13391339 </div>
13401340 </div>
13411341 </div>
13421342 <div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp, aphrodite" id="dynatemp_block_ooba" class="wide100p">
13431343 <h4 class="wide100p textAlignCenter">
13441344 <div class="flex-container alignitemscenter justifyCenter">
13451345 <div class="checkbox_label" for="dynatemp_textgenerationwebui">
@@ -1367,7 +1367,7 @@
13671367 </div>
13681368 </div>
13691369 </div>
13701370 <div data-tg-type="ooba,aphrodite,infermaticai,koboldcpp,llamacpp,mancer,ollama,tabby" id="mirostat_block_ooba" class="wide100p">
13711371 <h4 class="wide100p textAlignCenter">
13721372 <label data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat</label>
13731373 <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 @@
13961396 </div>
13971397 </div>
13981398 </div>
13991399 <div data-tg-type="ooba, vllm, aphrodite" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">
14001400 <h4 class="wide100p textAlignCenter">
14011401 <label>
14021402 <span data-i18n="Beam search">Beam Search</span>
@@ -1537,18 +1537,7 @@
15371537 </div>
15381538 </div>
15391539 </div>
15401540 <div id="json_schema_blockgrammar_block_ooba" data-tg-type="tabbyooba, llamacppaphrodite" class="wide100p">
1541- <hr class="wide100p">
1542- <h4 class="wide100p textAlignCenter"><span data-i18n="JSON Schema">JSON Schema</span>
1543- <a href="https://json-schema.org/learn/getting-started-step-by-step" target="_blank">
1544- <small>
1545- <div class="fa-solid fa-circle-question note-link-span"></div>
1546- </small>
1547- </a>
1548- </h4>
1549- <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>
1550- </div>
1551- <div id="grammar_block_ooba" class="wide100p">
15521541 <hr class="wide100p">
15531542 <h4 class="wide100p textAlignCenter">
15541543 <label>
@@ -1563,6 +1552,17 @@
15631552 </h4>
15641553 <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>
15651554 </div>
1555+ <div id="json_schema_block" data-tg-type="tabby, llamacpp, aphrodite" class="wide100p">
1556+ <hr class="wide100p">
1557+ <h4 class="wide100p textAlignCenter"><span data-i18n="JSON Schema">JSON Schema</span>
1558+ <a href="https://json-schema.org/learn/getting-started-step-by-step" target="_blank">
1559+ <small>
1560+ <div class="fa-solid fa-circle-question note-link-span"></div>
1561+ </small>
1562+ </a>
1563+ </h4>
1564+ <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>
1565+ </div>
15661566 <div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" class="range-block flexFlowColumn wide100p">
15671567 <hr class="wide100p">
15681568 <div class="range-block-title">
@@ -2425,7 +2425,7 @@
24252425 <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>
24262426 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
24272427 </div>
24282428 <label data-tg-type="ooba,aphrodite" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
24292429 <input type="checkbox" id="legacy_api_textgenerationwebui" />
24302430 <span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>
24312431 </label>
public/scripts/textgen-settings.js+33 -16
@@ -123,6 +123,7 @@ const settings = {
123123 rep_pen_slope: 1,
124124 no_repeat_ngram_size: 0,
125125 penalty_alpha: 0,
126+ use_beam_search: false,
126127 num_beams: 1,
127128 length_penalty: 1,
128129 min_length: 0,
@@ -162,14 +163,9 @@ const settings = {
162163 banned_tokens: '',
163164 sampler_priority: OOBA_DEFAULT_ORDER,
164165 samplers: LLAMACPP_DEFAULT_ORDER,
165- //n_aphrodite: 1,
166- //best_of_aphrodite: 1,
167166 ignore_eos_token: false,
168167 spaces_between_special_tokens: true,
169168 speculative_ngram: false,
170- //logits_processors_aphrodite: [],
171- //log_probs_aphrodite: 0,
172- //prompt_log_probs_aphrodite: 0,
173169 type: textgen_types.OOBA,
174170 mancer_model: 'mytholite',
175171 togetherai_model: 'Gryphe/MythoMax-L2-13b',
@@ -191,6 +187,8 @@ const settings = {
191187 openrouter_allow_fallbacks: true,
192188 xtc_threshold: 0.1,
193189 xtc_probability: 0,
190+ include_stop_str_in_output: false,
191+ guided_regex: '',
194192};
195193
196194export let textgenerationwebui_banned_in_macros = [];
@@ -250,14 +248,9 @@ export const setting_names = [
250248 'json_schema',
251249 'banned_tokens',
252250 'legacy_api',
253- //'n_aphrodite',
254- //'best_of_aphrodite',
255251 'ignore_eos_token',
256252 'spaces_between_special_tokens',
257253 'speculative_ngram',
258- //'logits_processors_aphrodite',
259- //'log_probs_aphrodite',
260- //'prompt_log_probs_aphrodite'
261254 'sampler_order',
262255 'sampler_priority',
263256 'samplers',
@@ -268,6 +261,8 @@ export const setting_names = [
268261 'openrouter_allow_fallbacks',
269262 'xtc_threshold',
270263 'xtc_probability',
264+ 'include_stop_str_in_output',
265+ 'guided_regex',
271266];
272267
273268const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba');
@@ -1208,13 +1203,35 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
12081203 };
12091204 const aphroditeParams = {
12101205 'n': canMultiSwipe ? settings.n : 1,
12111206 'best_offrequency_penalty': canMultiSwipe ? settings.n : 1freq_pen,
1207+ 'presence_penalty': settings.presence_pen,
1208+ 'repetition_penalty': settings.rep_pen,
1209+ 'seed': settings.seed,
1210+ 'stop': settings.stopping_strings,
1211+ 'temperature': settings.temp,
1212+ 'temperature_last': settings.temperature_last,
1213+ 'top_p': settings.top_p,
1214+ 'top_k': settings.top_k,
1215+ 'top_a': settings.top_a,
1216+ 'min_p': settings.min_p,
1217+ 'tfs': settings.tfs,
1218+ 'eta_cutoff': settings.eta_cutoff,
1219+ 'epsilon_cutoff': settings.epsilon_cutoff,
1220+ 'typical_p': settings.typical_p,
1221+ 'smoothing_factor': settings.smoothing_factor,
1222+ 'smoothing_curve': settings.smoothing_curve,
1223+ 'use_beam_search': settings.use_beam_search,
1224+ 'length_penalty': settings.length_penalty,
1225+ 'early_stopping': settings.early_stopping,
12121226 'ignore_eos': settings.ignore_eos_token,
1227+ 'min_tokens': settings.min_length,
1228+ 'skip_special_tokens': settings.skip_special_tokens,
1229+ 'include_stop_str_in_output': settings.include_stop_str_in_output,
12131230 'spaces_between_special_tokens': settings.spaces_between_special_tokens,
12141231 'grammarguided_grammar': settings.grammar_string,
12151232 //'logits_processorsguided_json': settings.logits_processors_aphroditejson_schema,
1216- //'logprobs': settings.log_probs_aphrodite,
1233+
1217- //'prompt_logprobs': settings.prompt_log_probs_aphrodite,
1234+
12181235 };
12191236
12201237 if (settings.type === OPENROUTER) {
@@ -1254,7 +1271,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
12541271 break;
12551272
12561273 case APHRODITE:
12571274 params = Object.assign(params, aphroditeParams);
12581275 break;
12591276
12601277 default: