Backport llama.cpp-related DRY fixes from staging (#3051) * llama.cpp Enable dry w/ array convert The new PR that was merged needs an array instead of a str https://github.com/ggerganov/llama.cpp/pull/9702 * Safe sequence breakers parse * Support comma-separated list of llama.cpp sequence breakers #3026 --------- Co-authored-by: Beinsezii <beinsezii@gmail.com>
Signed| @@ -1397,8 +1397,7 @@ | ||
| 1397 | 1397 | </div> |
| 1398 | 1398 | </div> |
| 1399 | 1399 | |
| 1400 | - <!-- Enable for llama.cpp when the PR is merged: https://github.com/ggerganov/llama.cpp/pull/6839 --> | |
| 1400 | + <div data-tg-type="ooba, koboldcpp, tabby, llamacpp" id="dryBlock" class="wide100p"> | |
| 1401 | - <div data-tg-type="ooba, koboldcpp, tabby" id="dryBlock" class="wide100p"> | |
| 1402 | 1401 | <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"> |
| 1403 | 1402 | <label data-i18n="DRY Repetition Penalty">DRY Repetition Penalty</label> |
| 1404 | 1403 | <a href="https://github.com/oobabooga/text-generation-webui/pull/5677" target="_blank"> |
| @@ -1307,11 +1307,23 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, | ||
| 1307 | 1307 | : []; |
| 1308 | 1308 | const tokenBans = toIntArray(banned_tokens); |
| 1309 | 1309 | logitBiasArray.push(...tokenBans.map(x => [Number(x), false])); |
| 1310 | + const sequenceBreakers = (() => { | |
| 1311 | + try { | |
| 1312 | + return JSON.parse(params.dry_sequence_breakers); | |
| 1313 | + } catch { | |
| 1314 | + if (typeof params.dry_sequence_breakers === 'string') { | |
| 1315 | + return params.dry_sequence_breakers.split(','); | |
| 1316 | + } | |
| 1317 | + | |
| 1318 | + return undefined; | |
| 1319 | + } | |
| 1320 | + })(); | |
| 1310 | 1321 | const llamaCppParams = { |
| 1311 | 1322 | 'logit_bias': logitBiasArray, |
| 1312 | 1323 | // Conflicts with ooba's grammar_string |
| 1313 | 1324 | 'grammar': settings.grammar_string, |
| 1314 | 1325 | 'cache_prompt': true, |
| 1326 | + 'dry_sequence_breakers': sequenceBreakers, | |
| 1315 | 1327 | }; |
| 1316 | 1328 | params = Object.assign(params, llamaCppParams); |
| 1317 | 1329 | } |