Implement "except" mode for type-specific controls in settings

cd0b83429187a94715419180befe9c8d5446d045

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +17 -9Ignore whitespace
public/index.html+10 -9
@@ -1235,7 +1235,8 @@
1235 <input class="neo-range-slider" type="range" id="temp_textgenerationwebui" name="volume" min="0.0" max="5.0" step="0.01" x-setting-id="temp">1235 <input class="neo-range-slider" type="range" id="temp_textgenerationwebui" name="volume" min="0.0" max="5.0" step="0.01" x-setting-id="temp">
1236 <input class="neo-range-input" type="number" min="0.0" max="5.0" step="0.01" data-for="temp_textgenerationwebui" id="temp_counter_textgenerationwebui">1236 <input class="neo-range-input" type="number" min="0.0" max="5.0" step="0.01" data-for="temp_textgenerationwebui" id="temp_counter_textgenerationwebui">
1237 </div>1237 </div>
1238 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1238 <!-- Note: "except" mode = show for all BUT types in data-tg-type -->
1239 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1239 <small>1240 <small>
1240 <span data-i18n="Top K">Top K</span>1241 <span data-i18n="Top K">Top K</span>
1241 <div class="fa-solid fa-circle-info opacity50p" title="Top K sets a maximum amount of top tokens that can be chosen from.&#13;E.g Top K is 20, this means only the 20 highest ranking tokens will be kept (regardless of their probabilities being diverse or limited).&#13;Set to 0 (or -1, depending on your backend) to disable." data-i18n="[title]Top_K_desc"></div>1242 <div class="fa-solid fa-circle-info opacity50p" title="Top K sets a maximum amount of top tokens that can be chosen from.&#13;E.g Top K is 20, this means only the 20 highest ranking tokens will be kept (regardless of their probabilities being diverse or limited).&#13;Set to 0 (or -1, depending on your backend) to disable." data-i18n="[title]Top_K_desc"></div>
@@ -1251,7 +1252,7 @@
1251 <input class="neo-range-slider" type="range" id="top_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">1252 <input class="neo-range-slider" type="range" id="top_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
1252 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_p_textgenerationwebui" id="top_p_counter_textgenerationwebui">1253 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_p_textgenerationwebui" id="top_p_counter_textgenerationwebui">
1253 </div>1254 </div>
1254 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1255 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1255 <small>1256 <small>
1256 <span data-i18n="Typical P">Typical P</span>1257 <span data-i18n="Typical P">Typical P</span>
1257 <div class="fa-solid fa-circle-info opacity50p" title="Typical P Sampling prioritizes tokens based on their deviation from the average entropy of the set.&#13;It maintains tokens whose cumulative probability is close to a predefined threshold (e.g., 0.5), emphasizing those with average information content.&#13;Set to 1.0 to disable." data-i18n="[title]Typical_P_desc"></div>1258 <div class="fa-solid fa-circle-info opacity50p" title="Typical P Sampling prioritizes tokens based on their deviation from the average entropy of the set.&#13;It maintains tokens whose cumulative probability is close to a predefined threshold (e.g., 0.5), emphasizing those with average information content.&#13;Set to 1.0 to disable." data-i18n="[title]Typical_P_desc"></div>
@@ -1259,7 +1260,7 @@
1259 <input class="neo-range-slider" type="range" id="typical_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">1260 <input class="neo-range-slider" type="range" id="typical_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
1260 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="typical_p_textgenerationwebui" id="typical_p_counter_textgenerationwebui">1261 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="typical_p_textgenerationwebui" id="typical_p_counter_textgenerationwebui">
1261 </div>1262 </div>
1262 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1263 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1263 <small>1264 <small>
1264 <span data-i18n="Min P">Min P</span>1265 <span data-i18n="Min P">Min P</span>
1265 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Min_P_desc" title="Min P sets a base minimum probability. This is scaled according to the top token's probability.&#13;E.g If Top token is 80% probability, and Min P is 0.1, only tokens higher than 8% would be considered.&#13;Set to 0 to disable."></div>1266 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Min_P_desc" title="Min P sets a base minimum probability. This is scaled according to the top token's probability.&#13;E.g If Top token is 80% probability, and Min P is 0.1, only tokens higher than 8% would be considered.&#13;Set to 0 to disable."></div>
@@ -1267,7 +1268,7 @@
1267 <input class="neo-range-slider" type="range" id="min_p_textgenerationwebui" name="volume" min="0" max="1" step="0.001">1268 <input class="neo-range-slider" type="range" id="min_p_textgenerationwebui" name="volume" min="0" max="1" step="0.001">
1268 <input class="neo-range-input" type="number" min="0" max="1" step="0.001" data-for="min_p_textgenerationwebui" id="min_p_counter_textgenerationwebui">1269 <input class="neo-range-input" type="number" min="0" max="1" step="0.001" data-for="min_p_textgenerationwebui" id="min_p_counter_textgenerationwebui">
1269 </div>1270 </div>
1270 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1271 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1271 <small>1272 <small>
1272 <span data-i18n="Top A">Top A</span>1273 <span data-i18n="Top A">Top A</span>
1273 <div class="fa-solid fa-circle-info opacity50p" title="Top A sets a threshold for token selection based on the square of the highest token probability.&#13;E.g if the Top-A value is 0.2 and the top token's probability is 50%, tokens with probabilities below 5% (0.2 * 0.5^2) are excluded.&#13;Set to 0 to disable." data-i18n="[title]Top_A_desc"></div>1274 <div class="fa-solid fa-circle-info opacity50p" title="Top A sets a threshold for token selection based on the square of the highest token probability.&#13;E.g if the Top-A value is 0.2 and the top token's probability is 50%, tokens with probabilities below 5% (0.2 * 0.5^2) are excluded.&#13;Set to 0 to disable." data-i18n="[title]Top_A_desc"></div>
@@ -1275,7 +1276,7 @@
1275 <input class="neo-range-slider" type="range" id="top_a_textgenerationwebui" name="volume" min="0" max="1" step="0.01">1276 <input class="neo-range-slider" type="range" id="top_a_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
1276 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_a_textgenerationwebui" id="top_a_counter_textgenerationwebui">1277 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_a_textgenerationwebui" id="top_a_counter_textgenerationwebui">
1277 </div>1278 </div>
1278 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1279 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1279 <small>1280 <small>
1280 <span data-i18n="TFS">TFS</span>1281 <span data-i18n="TFS">TFS</span>
1281 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Tail_Free_Sampling_desc" title="Tail-Free Sampling (TFS) searches for a tail of low-probability tokens in the distribution,&#13;by analyzing the rate of change in token probabilities using derivatives. It retains tokens up to a threshold (e.g., 0.3) based on the normalized second derivative.&#13;The closer to 0, the more discarded tokens. Set to 1.0 to disable."></div>1282 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Tail_Free_Sampling_desc" title="Tail-Free Sampling (TFS) searches for a tail of low-probability tokens in the distribution,&#13;by analyzing the rate of change in token probabilities using derivatives. It retains tokens up to a threshold (e.g., 0.3) based on the normalized second derivative.&#13;The closer to 0, the more discarded tokens. Set to 1.0 to disable."></div>
@@ -1307,7 +1308,7 @@
1307 <input class="neo-range-slider" type="range" id="eta_cutoff_textgenerationwebui" name="volume" min="0" max="20" step="0.01">1308 <input class="neo-range-slider" type="range" id="eta_cutoff_textgenerationwebui" name="volume" min="0" max="20" step="0.01">
1308 <input class="neo-range-input" type="number" min="0" max="20" step="0.01" data-for="eta_cutoff_textgenerationwebui" id="eta_cutoff_counter_textgenerationwebui">1309 <input class="neo-range-input" type="number" min="0" max="20" step="0.01" data-for="eta_cutoff_textgenerationwebui" id="eta_cutoff_counter_textgenerationwebui">
1309 </div>1310 </div>
1310 <div class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">1311 <div data-tg-type-mode="except" data-tg-type="generic" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
1311 <small data-i18n="rep.pen">Repetition Penalty</small>1312 <small data-i18n="rep.pen">Repetition Penalty</small>
1312 <input class="neo-range-slider" type="range" id="rep_pen_textgenerationwebui" name="volume" min="1" max="3" step="0.01">1313 <input class="neo-range-slider" type="range" id="rep_pen_textgenerationwebui" name="volume" min="1" max="3" step="0.01">
1313 <input class="neo-range-input" type="number" min="1" max="3" step="0.01" data-for="rep_pen_textgenerationwebui" id="rep_pen_counter_textgenerationwebui">1314 <input class="neo-range-input" type="number" min="1" max="3" step="0.01" data-for="rep_pen_textgenerationwebui" id="rep_pen_counter_textgenerationwebui">
@@ -1569,7 +1570,7 @@
1569 <small data-i18n="Ignore EOS Token">Ignore EOS Token</small>1570 <small data-i18n="Ignore EOS Token">Ignore EOS Token</small>
1570 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Ignore the EOS Token even if it generates." title="Ignore the EOS Token even if it generates."></div>1571 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Ignore the EOS Token even if it generates." title="Ignore the EOS Token even if it generates."></div>
1571 </label>1572 </label>
1572 <label class="checkbox_label flexGrow flexShrink" for="skip_special_tokens_textgenerationwebui">1573 <label data-tg-type-mode="except" data-tg-type="generic" class="checkbox_label flexGrow flexShrink" for="skip_special_tokens_textgenerationwebui">
1573 <input type="checkbox" id="skip_special_tokens_textgenerationwebui" />1574 <input type="checkbox" id="skip_special_tokens_textgenerationwebui" />
1574 <small data-i18n="Skip Special Tokens">Skip Special Tokens</small>1575 <small data-i18n="Skip Special Tokens">Skip Special Tokens</small>
1575 </label>1576 </label>
@@ -1594,14 +1595,14 @@
1594 </label>1595 </label>
1595 </div>1596 </div>
1596 </div>1597 </div>
1597 <div data-tg-type="mancer, ooba, koboldcpp, vllm, aphrodite, llamacpp, ollama, infermaticai, huggingface" class="flex-container flexFlowColumn alignitemscenter flexBasis48p flexGrow flexShrink gap0">1598 <div data-tg-type="mancer, ooba, koboldcpp, vllm, aphrodite, llamacpp, ollama, infermaticai, huggingface, generic" class="flex-container flexFlowColumn alignitemscenter flexBasis48p flexGrow flexShrink gap0">
1598 <label>1599 <label>
1599 <small data-i18n="Seed">Seed</small>1600 <small data-i18n="Seed">Seed</small>
1600 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Seed_desc" title="A random seed to use for deterministic and reproducable outputs. Set to -1 to use a random seed."></div>1601 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Seed_desc" title="A random seed to use for deterministic and reproducable outputs. Set to -1 to use a random seed."></div>
1601 </label>1602 </label>
1602 <input type="number" id="seed_textgenerationwebui" class="text_pole textAlignCenter" min="-1" value="-1" />1603 <input type="number" id="seed_textgenerationwebui" class="text_pole textAlignCenter" min="-1" value="-1" />
1603 </div>1604 </div>
1604 <div id="banned_tokens_block_ooba" class="wide100p">1605 <div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
1605 <hr class="width100p">1606 <hr class="width100p">
1606 <h4 class="range-block-title justifyCenter">1607 <h4 class="range-block-title justifyCenter">
1607 <span data-i18n="Banned Tokens">Banned Tokens/Strings</span>1608 <span data-i18n="Banned Tokens">Banned Tokens/Strings</span>
public/scripts/textgen-settings.js+7 -0
@@ -838,7 +838,14 @@ jQuery(function () {
838838
839function showTypeSpecificControls(type) {839function showTypeSpecificControls(type) {
840 $('[data-tg-type]').each(function () {840 $('[data-tg-type]').each(function () {
841 const mode = String($(this).attr('data-tg-type-mode') ?? '').toLowerCase().trim();
841 const tgTypes = $(this).attr('data-tg-type').split(',').map(x => x.trim());842 const tgTypes = $(this).attr('data-tg-type').split(',').map(x => x.trim());
843
844 if (mode === 'except') {
845 $(this)[tgTypes.includes(type) ? 'hide' : 'show']();
846 return;
847 }
848
842 for (const tgType of tgTypes) {849 for (const tgType of tgTypes) {
843 if (tgType === type || tgType == 'all') {850 if (tgType === type || tgType == 'all') {
844 $(this).show();851 $(this).show();