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 @@
1189 <input class="neo-range-slider" type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.01">1189 <input class="neo-range-slider" type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
1190 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">1190 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">
1191 </div>1191 </div>
1192 <div data-tg-type="ooba,mancer" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1192 <div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1193 <small>1193 <small>
1194 <span data-i18n="Epsilon Cutoff">Epsilon Cutoff</span>1194 <span data-i18n="Epsilon Cutoff">Epsilon Cutoff</span>
1195 <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>1195 <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 @@
1197 <input class="neo-range-slider" type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">1197 <input class="neo-range-slider" type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">
1198 <input class="neo-range-input" type="number" min="0" max="9" step="0.01" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">1198 <input class="neo-range-input" type="number" min="0" max="9" step="0.01" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">
1199 </div>1199 </div>
1200 <div data-tg-type="ooba,mancer" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1200 <div data-tg-type="ooba,mancer,aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1201 <small>1201 <small>
1202 <span data-i18n="Eta Cutoff">Eta Cutoff</span>1202 <span data-i18n="Eta Cutoff">Eta Cutoff</span>
1203 <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>1203 <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 @@
1250 <input class="neo-range-slider" type="range" id="skew_textgenerationwebui" name="volume" min="-5" max="5" step="0.01" />1250 <input class="neo-range-slider" type="range" id="skew_textgenerationwebui" name="volume" min="-5" max="5" step="0.01" />
1251 <input class="neo-range-input" type="number" min="-5" max="5" step="0.01" data-for="skew_textgenerationwebui" id="skew_counter_textgenerationwebui">1251 <input class="neo-range-input" type="number" min="-5" max="5" step="0.01" data-for="skew_textgenerationwebui" id="skew_counter_textgenerationwebui">
1252 </div>1252 </div>
1253 <div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1253 <div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai, aphrodite" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1254 <small data-i18n="Min Length">Min Length</small>1254 <small data-i18n="Min Length">Min Length</small>
1255 <input class="neo-range-slider" type="range" id="min_length_textgenerationwebui" name="volume" min="0" max="2000" step="1" />1255 <input class="neo-range-slider" type="range" id="min_length_textgenerationwebui" name="volume" min="0" max="2000" step="1" />
1256 <input class="neo-range-input" type="number" min="0" max="2000" step="1" data-for="min_length_textgenerationwebui" id="min_length_counter_textgenerationwebui">1256 <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 @@
1339 </div>1339 </div>
1340 </div>1340 </div>
1341 </div>1341 </div>
1342 <div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp, aphrodite" id="dynatemp_block_ooba" class="wide100p">1342 <div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp" id="dynatemp_block_ooba" class="wide100p">
1343 <h4 class="wide100p textAlignCenter">1343 <h4 class="wide100p textAlignCenter">
1344 <div class="flex-container alignitemscenter justifyCenter">1344 <div class="flex-container alignitemscenter justifyCenter">
1345 <div class="checkbox_label" for="dynatemp_textgenerationwebui">1345 <div class="checkbox_label" for="dynatemp_textgenerationwebui">
@@ -1367,7 +1367,7 @@
1367 </div>1367 </div>
1368 </div>1368 </div>
1369 </div>1369 </div>
1370 <div data-tg-type="ooba,aphrodite,infermaticai,koboldcpp,llamacpp,mancer,ollama,tabby" id="mirostat_block_ooba" class="wide100p">1370 <div data-tg-type="ooba,infermaticai,koboldcpp,llamacpp,mancer,ollama,tabby" id="mirostat_block_ooba" class="wide100p">
1371 <h4 class="wide100p textAlignCenter">1371 <h4 class="wide100p textAlignCenter">
1372 <label data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat</label>1372 <label data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat</label>
1373 <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>1373 <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 @@
1396 </div>1396 </div>
1397 </div>1397 </div>
1398 </div>1398 </div>
1399 <div data-tg-type="ooba, vllm" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">1399 <div data-tg-type="ooba, vllm, aphrodite" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">
1400 <h4 class="wide100p textAlignCenter">1400 <h4 class="wide100p textAlignCenter">
1401 <label>1401 <label>
1402 <span data-i18n="Beam search">Beam Search</span>1402 <span data-i18n="Beam search">Beam Search</span>
@@ -1537,18 +1537,7 @@
1537 </div>1537 </div>
1538 </div>1538 </div>
1539 </div>1539 </div>
1540 <div id="json_schema_block" data-tg-type="tabby, llamacpp" class="wide100p">1540 <div id="grammar_block_ooba" data-tg-type="ooba,aphrodite" 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">
1552 <hr class="wide100p">1541 <hr class="wide100p">
1553 <h4 class="wide100p textAlignCenter">1542 <h4 class="wide100p textAlignCenter">
1554 <label>1543 <label>
@@ -1563,6 +1552,17 @@
1563 </h4>1552 </h4>
1564 <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>1553 <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>
1565 </div>1554 </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>
1566 <div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" class="range-block flexFlowColumn wide100p">1566 <div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" class="range-block flexFlowColumn wide100p">
1567 <hr class="wide100p">1567 <hr class="wide100p">
1568 <div class="range-block-title">1568 <div class="range-block-title">
@@ -2425,7 +2425,7 @@
2425 <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>2425 <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>
2426 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>2426 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
2427 </div>2427 </div>
2428 <label data-tg-type="ooba,aphrodite" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">2428 <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
2429 <input type="checkbox" id="legacy_api_textgenerationwebui" />2429 <input type="checkbox" id="legacy_api_textgenerationwebui" />
2430 <span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>2430 <span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>
2431 </label>2431 </label>
public/scripts/textgen-settings.js+33 -16
@@ -123,6 +123,7 @@ const settings = {
123 rep_pen_slope: 1,123 rep_pen_slope: 1,
124 no_repeat_ngram_size: 0,124 no_repeat_ngram_size: 0,
125 penalty_alpha: 0,125 penalty_alpha: 0,
126 use_beam_search: false,
126 num_beams: 1,127 num_beams: 1,
127 length_penalty: 1,128 length_penalty: 1,
128 min_length: 0,129 min_length: 0,
@@ -162,14 +163,9 @@ const settings = {
162 banned_tokens: '',163 banned_tokens: '',
163 sampler_priority: OOBA_DEFAULT_ORDER,164 sampler_priority: OOBA_DEFAULT_ORDER,
164 samplers: LLAMACPP_DEFAULT_ORDER,165 samplers: LLAMACPP_DEFAULT_ORDER,
165 //n_aphrodite: 1,
166 //best_of_aphrodite: 1,
167 ignore_eos_token: false,166 ignore_eos_token: false,
168 spaces_between_special_tokens: true,167 spaces_between_special_tokens: true,
169 speculative_ngram: false,168 speculative_ngram: false,
170 //logits_processors_aphrodite: [],
171 //log_probs_aphrodite: 0,
172 //prompt_log_probs_aphrodite: 0,
173 type: textgen_types.OOBA,169 type: textgen_types.OOBA,
174 mancer_model: 'mytholite',170 mancer_model: 'mytholite',
175 togetherai_model: 'Gryphe/MythoMax-L2-13b',171 togetherai_model: 'Gryphe/MythoMax-L2-13b',
@@ -191,6 +187,8 @@ const settings = {
191 openrouter_allow_fallbacks: true,187 openrouter_allow_fallbacks: true,
192 xtc_threshold: 0.1,188 xtc_threshold: 0.1,
193 xtc_probability: 0,189 xtc_probability: 0,
190 include_stop_str_in_output: false,
191 guided_regex: '',
194};192};
195193
196export let textgenerationwebui_banned_in_macros = [];194export let textgenerationwebui_banned_in_macros = [];
@@ -250,14 +248,9 @@ export const setting_names = [
250 'json_schema',248 'json_schema',
251 'banned_tokens',249 'banned_tokens',
252 'legacy_api',250 'legacy_api',
253 //'n_aphrodite',
254 //'best_of_aphrodite',
255 'ignore_eos_token',251 'ignore_eos_token',
256 'spaces_between_special_tokens',252 'spaces_between_special_tokens',
257 'speculative_ngram',253 'speculative_ngram',
258 //'logits_processors_aphrodite',
259 //'log_probs_aphrodite',
260 //'prompt_log_probs_aphrodite'
261 'sampler_order',254 'sampler_order',
262 'sampler_priority',255 'sampler_priority',
263 'samplers',256 'samplers',
@@ -268,6 +261,8 @@ export const setting_names = [
268 'openrouter_allow_fallbacks',261 'openrouter_allow_fallbacks',
269 'xtc_threshold',262 'xtc_threshold',
270 'xtc_probability',263 'xtc_probability',
264 'include_stop_str_in_output',
265 'guided_regex',
271];266];
272267
273const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba');268const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba');
@@ -1208,13 +1203,35 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
1208 };1203 };
1209 const aphroditeParams = {1204 const aphroditeParams = {
1210 'n': canMultiSwipe ? settings.n : 1,1205 'n': canMultiSwipe ? settings.n : 1,
1211 'best_of': canMultiSwipe ? settings.n : 1,1206 'frequency_penalty': settings.freq_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,
1212 'ignore_eos': settings.ignore_eos_token,1226 '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,
1213 'spaces_between_special_tokens': settings.spaces_between_special_tokens,1230 'spaces_between_special_tokens': settings.spaces_between_special_tokens,
1214 'grammar': settings.grammar_string,1231 'guided_grammar': settings.grammar_string,
1215 //'logits_processors': settings.logits_processors_aphrodite,1232 'guided_json': settings.json_schema,
1216 //'logprobs': settings.log_probs_aphrodite,1233
1217 //'prompt_logprobs': settings.prompt_log_probs_aphrodite,1234
1218 };1235 };
12191236
1220 if (settings.type === OPENROUTER) {1237 if (settings.type === OPENROUTER) {
@@ -1254,7 +1271,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
1254 break;1271 break;
12551272
1256 case APHRODITE:1273 case APHRODITE:
1257 params = Object.assign(params, aphroditeParams);1274 params = Object.assign(aphroditeParams);
1258 break;1275 break;
12591276
1260 default:1277 default: