Skip to content

Commit

Permalink
Backport llama.cpp-related DRY fixes from staging (SillyTavern#3051)
Browse files Browse the repository at this point in the history
* llama.cpp Enable dry w/ array convert

The new PR that was merged needs an array instead of a str

ggerganov/llama.cpp#9702

* Safe sequence breakers parse

* Support comma-separated list of llama.cpp sequence breakers SillyTavern#3026

---------

Co-authored-by: Beinsezii <[email protected]>
  • Loading branch information
Cohee1207 and Beinsezii authored Nov 6, 2024
1 parent fb48d25 commit a3ca407
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,7 @@ <h4 class="wide100p textAlignCenter">
</div>
</div>

<!-- Enable for llama.cpp when the PR is merged: https://github.com/ggerganov/llama.cpp/pull/6839 -->
<div data-tg-type="ooba, koboldcpp, tabby" id="dryBlock" class="wide100p">
<div data-tg-type="ooba, koboldcpp, tabby, llamacpp" id="dryBlock" class="wide100p">
<h4 class="wide100p textAlignCenter" title="DRY penalizes tokens that would extend the end of the input into a sequence that has previously occurred in the input. Set multiplier to 0 to disable." data-i18n="[title]DRY_Repetition_Penalty_desc">
<label data-i18n="DRY Repetition Penalty">DRY Repetition Penalty</label>
<a href="https://github.com/oobabooga/text-generation-webui/pull/5677" target="_blank">
Expand Down
12 changes: 12 additions & 0 deletions public/scripts/textgen-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1307,11 +1307,23 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
: [];
const tokenBans = toIntArray(banned_tokens);
logitBiasArray.push(...tokenBans.map(x => [Number(x), false]));
const sequenceBreakers = (() => {
try {
return JSON.parse(params.dry_sequence_breakers);
} catch {
if (typeof params.dry_sequence_breakers === 'string') {
return params.dry_sequence_breakers.split(',');
}

return undefined;
}
})();
const llamaCppParams = {
'logit_bias': logitBiasArray,
// Conflicts with ooba's grammar_string
'grammar': settings.grammar_string,
'cache_prompt': true,
'dry_sequence_breakers': sequenceBreakers,
};
params = Object.assign(params, llamaCppParams);
}
Expand Down

0 comments on commit a3ca407

Please sign in to comment.