From e77c1d33a67d3fd0873acbcbea3069b7d49a167d Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:43:31 +0200 Subject: [PATCH] Fix logit bias with best match tokenizer Fixes #5017 --- public/scripts/textgen-settings.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 0fc6ea370..0f731cec9 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -24,7 +24,7 @@ import { getActiveManualApiSamplers, loadApiSelectedSamplers, isSamplerManualPri import { SECRET_KEYS, writeSecret } from './secrets.js'; import { getEventSourceStream } from './sse-stream.js'; import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, loadAphroditeModels, loadDreamGenModels, loadFeatherlessModels, loadGenericModels, loadInfermaticAIModels, loadLlamaCppModels, loadMancerModels, loadOllamaModels, loadOpenRouterModels, loadTabbyModels, loadTogetherAIModels, loadVllmModels } from './textgen-models.js'; -import { ENCODE_TOKENIZERS, TEXTGEN_TOKENIZERS, TOKENIZER_SUPPORTED_KEY, getTextTokens, tokenizers } from './tokenizers.js'; +import { ENCODE_TOKENIZERS, TEXTGEN_TOKENIZERS, TOKENIZER_SUPPORTED_KEY, getTextTokens, getTokenizerBestMatch, tokenizers } from './tokenizers.js'; import { AbortReason } from './util/AbortReason.js'; import { getSortableDelay, onlyUnique, arraysEqual, isObject } from './utils.js'; @@ -403,6 +403,11 @@ function convertPresets(presets) { } function getTokenizerForTokenIds() { + const bestMatchTokenizer = getTokenizerBestMatch('textgenerationwebui'); + if (bestMatchTokenizer === tokenizers.API_TEXTGENERATIONWEBUI) { + return tokenizers.API_CURRENT; + } + if (power_user.tokenizer === tokenizers.API_CURRENT && TEXTGEN_TOKENIZERS.includes(textgenerationwebui_settings.type)) { return tokenizers.API_CURRENT; } @@ -658,6 +663,9 @@ async function getStatusTextgen() { return resultCheckStatus(); } + // Clear logit bias cache + BIAS_CACHE.delete(BIAS_KEY); + if ([textgen_types.GENERIC, textgen_types.OOBA].includes(textgenerationwebui_settings.type) && textgenerationwebui_settings.bypass_status_check) { setOnlineStatus(t`Status check bypassed`); return resultCheckStatus();