Add TFS and Top A to ooba API

This commit is contained in:
SillyLossy
2023-05-30 13:07:52 +03:00
parent 903d79e6b5
commit a0090929ae
20 changed files with 118 additions and 46 deletions

View File

@ -3,6 +3,8 @@
"top_p": 0.92, "top_p": 0.92,
"top_k": 150, "top_k": 150,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 4.5, "rep_pen": 4.5,
"no_repeat_ngram_size": 2, "no_repeat_ngram_size": 2,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 1, "top_p": 1,
"top_k": 4, "top_k": 4,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1, "rep_pen": 1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0.6, "penalty_alpha": 0.6,

View File

@ -3,6 +3,8 @@
"top_p": 0.5, "top_p": 0.5,
"top_k": 40, "top_k": 40,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.2, "rep_pen": 1.2,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 1, "top_p": 1,
"top_k": 50, "top_k": 50,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1, "rep_pen": 1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.5, "top_p": 0.5,
"top_k": 0, "top_k": 0,
"typical_p": 0.19, "typical_p": 0.19,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.1, "rep_pen": 1.1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 1, "top_p": 1,
"top_k": 0, "top_k": 0,
"typical_p": 0.6, "typical_p": 0.6,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.1, "rep_pen": 1.1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.1, "top_p": 0.1,
"top_k": 40, "top_k": 40,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.18, "rep_pen": 1.18,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.85, "top_p": 0.85,
"top_k": 50, "top_k": 50,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1, "rep_pen": 1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.9, "top_p": 0.9,
"top_k": 100, "top_k": 100,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.15, "rep_pen": 1.15,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -4,6 +4,8 @@
"top_k": 100, "top_k": 100,
"typical_p": 0.97, "typical_p": 0.97,
"rep_pen": 1, "rep_pen": 1,
"top_a": 0,
"tfs": 1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,
"num_beams": 1, "num_beams": 1,

View File

@ -3,6 +3,8 @@
"top_p": 0.98, "top_p": 0.98,
"top_k": 0, "top_k": 0,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.05, "rep_pen": 1.05,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.85, "top_p": 0.85,
"top_k": 12, "top_k": 12,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.15, "rep_pen": 1.15,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 1, "top_p": 1,
"top_k": 100, "top_k": 100,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.05, "rep_pen": 1.05,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 1, "top_p": 1,
"top_k": 0, "top_k": 0,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.15, "rep_pen": 1.15,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.18, "top_p": 0.18,
"top_k": 30, "top_k": 30,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.15, "rep_pen": 1.15,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.73, "top_p": 0.73,
"top_k": 0, "top_k": 0,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.1, "rep_pen": 1.1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -3,6 +3,8 @@
"top_p": 0.9, "top_p": 0.9,
"top_k": 0, "top_k": 0,
"typical_p": 1, "typical_p": 1,
"top_a": 0,
"tfs": 1,
"rep_pen": 1.1, "rep_pen": 1.1,
"no_repeat_ngram_size": 0, "no_repeat_ngram_size": 0,
"penalty_alpha": 0, "penalty_alpha": 0,

View File

@ -156,7 +156,7 @@
<div class="range-block-range-and-counter"> <div class="range-block-range-and-counter">
<div class="range-block-range-and-counter"> <div class="range-block-range-and-counter">
<div class="range-block-range"> <div class="range-block-range">
<input type="range" id="amount_gen" name="volume" min="16" max="512" step="1"> <input type="range" id="amount_gen" name="volume" min="16" max="1024" step="1">
</div> </div>
<div class="range-block-counter"> <div class="range-block-counter">
<div contenteditable="true" data-for="amount_gen" id="amount_gen_counter"> <div contenteditable="true" data-for="amount_gen" id="amount_gen_counter">
@ -743,6 +743,36 @@
</div> </div>
</div> </div>
</div> </div>
<div class="range-block">
<div class="range-block-title">
Top A
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="top_a_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="top_a_textgenerationwebui" id="top_a_counter_textgenerationwebui">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title">
Tail Free Sampling
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">
select
</div>
</div>
</div>
</div>
<div class="range-block"> <div class="range-block">
<label class="checkbox_label" for="streaming_textgenerationwebui"> <label class="checkbox_label" for="streaming_textgenerationwebui">
<input type="checkbox" id="streaming_textgenerationwebui" /> <input type="checkbox" id="streaming_textgenerationwebui" />

View File

@ -13,6 +13,7 @@ import {
textgenerationwebui_settings, textgenerationwebui_settings,
loadTextGenSettings, loadTextGenSettings,
generateTextGenWithStreaming, generateTextGenWithStreaming,
getTextGenGenerationData,
} from "./scripts/textgen-settings.js"; } from "./scripts/textgen-settings.js";
import { import {
@ -3000,33 +3001,6 @@ function setInContextMessages(lastmsg, type) {
$('#chat .mes:not([is_system="true"])').eq(-lastmsg).addClass('lastInContext'); $('#chat .mes:not([is_system="true"])').eq(-lastmsg).addClass('lastInContext');
} }
// TODO: move to textgen-settings.js
function getTextGenGenerationData(finalPromt, this_amount_gen, isImpersonate) {
return {
'prompt': finalPromt,
'max_new_tokens': this_amount_gen,
'do_sample': textgenerationwebui_settings.do_sample,
'temperature': textgenerationwebui_settings.temp,
'top_p': textgenerationwebui_settings.top_p,
'typical_p': textgenerationwebui_settings.typical_p,
'repetition_penalty': textgenerationwebui_settings.rep_pen,
'encoder_repetition_penalty': textgenerationwebui_settings.encoder_rep_pen,
'top_k': textgenerationwebui_settings.top_k,
'min_length': textgenerationwebui_settings.min_length,
'no_repeat_ngram_size': textgenerationwebui_settings.no_repeat_ngram_size,
'num_beams': textgenerationwebui_settings.num_beams,
'penalty_alpha': textgenerationwebui_settings.penalty_alpha,
'length_penalty': textgenerationwebui_settings.length_penalty,
'early_stopping': textgenerationwebui_settings.early_stopping,
'seed': textgenerationwebui_settings.seed,
'add_bos_token': textgenerationwebui_settings.add_bos_token,
'stopping_strings': getStoppingStrings(isImpersonate, false),
'truncation_length': max_context,
'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
};
}
// TODO: move to nai-settings.js // TODO: move to nai-settings.js
function getNovelGenerationData(finalPromt, this_settings, this_amount_gen) { function getNovelGenerationData(finalPromt, this_settings, this_amount_gen) {
return { return {

View File

@ -1,5 +1,7 @@
import { import {
getRequestHeaders, getRequestHeaders,
getStoppingStrings,
max_context,
saveSettingsDebounced, saveSettingsDebounced,
} from "../script.js"; } from "../script.js";
@ -13,6 +15,8 @@ let textgenerationwebui_settings = {
temp: 0.7, temp: 0.7,
top_p: 0.5, top_p: 0.5,
top_k: 40, top_k: 40,
top_a: 0,
tfs: 1,
typical_p: 1, typical_p: 1,
rep_pen: 1.2, rep_pen: 1.2,
no_repeat_ngram_size: 0, no_repeat_ngram_size: 0,
@ -43,6 +47,8 @@ const setting_names = [
"no_repeat_ngram_size", "no_repeat_ngram_size",
"top_k", "top_k",
"top_p", "top_p",
"top_a",
"tfs",
"typical_p", "typical_p",
"penalty_alpha", "penalty_alpha",
"num_beams", "num_beams",
@ -186,3 +192,31 @@ async function generateTextGenWithStreaming(generate_data, signal) {
} }
} }
} }
export function getTextGenGenerationData(finalPromt, this_amount_gen, isImpersonate) {
return {
'prompt': finalPromt,
'max_new_tokens': this_amount_gen,
'do_sample': textgenerationwebui_settings.do_sample,
'temperature': textgenerationwebui_settings.temp,
'top_p': textgenerationwebui_settings.top_p,
'typical_p': textgenerationwebui_settings.typical_p,
'repetition_penalty': textgenerationwebui_settings.rep_pen,
'encoder_repetition_penalty': textgenerationwebui_settings.encoder_rep_pen,
'top_k': textgenerationwebui_settings.top_k,
'min_length': textgenerationwebui_settings.min_length,
'no_repeat_ngram_size': textgenerationwebui_settings.no_repeat_ngram_size,
'num_beams': textgenerationwebui_settings.num_beams,
'penalty_alpha': textgenerationwebui_settings.penalty_alpha,
'length_penalty': textgenerationwebui_settings.length_penalty,
'early_stopping': textgenerationwebui_settings.early_stopping,
'seed': textgenerationwebui_settings.seed,
'add_bos_token': textgenerationwebui_settings.add_bos_token,
'stopping_strings': getStoppingStrings(isImpersonate, false),
'truncation_length': max_context,
'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
'top_a': textgenerationwebui_settings.top_a,
'tfs': textgenerationwebui_settings.tfs,
};
}