You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Co-authored-by: l3utterfly <[email protected]>
Co-authored-by: pi6am <[email protected]>
* Implementation of DRY Sampling (post-sampling-refactor)
* Better merge of latest changes to master in server.cpp
* Added co-authors, testing, fix for consistent prompt sampling
* Misc. cleanup
* Remove debug define
* Fixing strict compile errors, cleaning up
* Removed unnecessary include
* Removed debugging code, moved (de)tokenizing functions
* Bug fixes to z-alg implementation
* small fix for string_format
* restoring Koboldcpp comments, adding attribution in llama.h and llama-sampling.cpp
* fixes, adjustments from code review
* Removing sequence breaker functions
* Addressed warnings from pedantic compile
* Trying alternative ways to pull in external tokenize/detoneize functions
* Removed C++ version of llama_sampler_init_dry
* Implemented testing code
* Switched to using llama_tokenize_internal
* Removed support for JSON-within-JSON for seq breakers
* Removed old llama_sampler_init_dry declaration
* Trying ggerganov's suggestion with llama_n_ctx_train
* Using vocab instead of model
* Restored common_sampler_init signature, using llama_n_ctx_train for context, updated testing code
* Minor cleanup
* Added --dry-sequence-breaker arg for single breaker, fixed docs and default values
* Removed mixed arrays for prompt
string_format("set allowed length for DRY sampling (default: %d)", params.sparams.dry_allowed_length),
1024
+
[](common_params & params, int value) {
1025
+
params.sparams.dry_allowed_length = value;
1026
+
}
1027
+
).set_sparam());
1028
+
add_opt(common_arg(
1029
+
{"--dry-penalty-last-n"}, "N",
1030
+
string_format("set DRY penalty for the last n tokens (default: %d, 0 = disable, -1 = context size)", params.sparams.dry_penalty_last_n),
1031
+
[](common_params & params, int value) {
1032
+
params.sparams.dry_penalty_last_n = value;
1033
+
}
1034
+
).set_sparam());
1035
+
add_opt(common_arg(
1036
+
{"--dry-sequence-breaker"}, "STRING",
1037
+
string_format("add sequence breaker for DRY sampling, clearing out default breakers (%s) in the process; use \"none\" to not use any sequence breakers\n",
Copy file name to clipboardExpand all lines: examples/main/README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,6 +187,30 @@ Use the `--no-penalize-nl` option to disable newline penalization when applying
187
187
188
188
Example usage: `--repeat-penalty 1.15 --repeat-last-n 128 --no-penalize-nl`
189
189
190
+
### DRY Repetition Penalty
191
+
192
+
DRY (Don't Repeat Yourself) sampling is an effective technique for reducing repetition in generated text even across long contexts by penalizing tokens based on their recent usage patterns (original [PR link](https://github.com/oobabooga/text-generation-webui/pull/5677)).
193
+
194
+
-`--dry-multiplier N`: Set the DRY sampling multiplier (default: 0.0, 0.0 = disabled).
195
+
-`--dry-base N`: Set the DRY sampling base value (default: 1.75).
196
+
-`--dry-allowed-length N`: Set the allowed length for DRY sampling (default: 2).
197
+
-`--dry-penalty-last-n N`: Set DRY penalty for the last n tokens (default: -1, 0 = disable, -1 = context size).
198
+
-`--dry-sequence-breaker STRING`: Add a sequence breaker for DRY sampling. Can be used more than once to add multiple sequence breakers. Using this clears out the default breakers, which consist of: `['\n', ':', '"', '*']`. If the string `"none"` is supplied, no sequence breakers are used.
199
+
200
+
The `dry-multiplier` option controls the strength of the DRY sampling effect. A value of 0.0 disables DRY sampling, while higher values increase its influence. A typical recommended value is 0.8.
201
+
202
+
The `dry-base` option sets the base value for the exponential penalty calculation in DRY sampling. Higher values lead to more aggressive penalization of repetitions.
203
+
204
+
The `dry-allowed-length` option sets the maximum length of repeated sequences that will not be penalized. Repetitions shorter than or equal to this length are not penalized, allowing for natural repetitions of short phrases or common words.
205
+
206
+
The `dry-penalty-last-n` option controls how many recent tokens to consider when applying the DRY penalty. A value of -1 considers the entire context. Use a positive value to limit the consideration to a specific number of recent tokens.
207
+
208
+
The `dry-sequence-breaker` option adds a single sequence breaker and can be used more than once to specify multiple sequence breakers. Sequence breakers interrupt sequence matching and break the input into parts where matching can be applied.
209
+
210
+
DRY sampling provides more nuanced control over text generation, particularly for reducing long-range repetitions and maintaining global coherence.
|`--dry-base N`| DRY sampling base value (default: 1.75) |
119
+
|`--dry-allowed-length N`| allowed length for DRY sampling (default: 2) |
120
+
|`--dry-penalty-last-n N`| DRY penalty for the last n tokens (default: -1, 0 = disable, -1 = context size) |
121
+
| `--dry-sequence-breaker STRING` | add sequence breaker for DRY sampling, clearing out default breakers (`['\n', ':', '"', '*']`) in the process; use `"none"` to not use any sequence breakers
117
122
|`--dynatemp-range N`| dynamic temperature range (default: 0.0, 0.0 = disabled) |
118
123
|`--dynatemp-exp N`| dynamic temperature exponent (default: 1.0) |
119
124
|`--mirostat N`| use Mirostat sampling.<br/>Top K, Nucleus, Tail Free and Locally Typical samplers are ignored if used.<br/>(default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0) |
@@ -357,6 +362,16 @@ node index.js
357
362
358
363
`frequency_penalty`: Repeat alpha frequency penalty. Default: `0.0`, which is disabled.
359
364
365
+
`dry_multiplier`: Set the DRY (Don't Repeat Yourself) repetition penalty multiplier. Default: `0.0`, which is disabled.
366
+
367
+
`dry_base`: Set the DRY repetition penalty base value. Default: `1.75`
368
+
369
+
`dry_allowed_length`: Tokens that extend repetition beyond this receive exponentially increasing penalty: multiplier * base ^ (length of repeating sequence before token - allowed length). Default: `2`
370
+
371
+
`dry_penalty_last_n`: How many tokens to scan for repetitions. Default: `-1`, where `0` is disabled and `-1` is context size.
372
+
373
+
`dry_sequence_breakers`: Specify an array of sequence breakers for DRY sampling. Only a JSON array of strings is accepted. Default: `['\n', ':', '"', '*']`
374
+
360
375
`mirostat`: Enable Mirostat sampling, controlling perplexity during text generation. Default: `0`, where `0` is disabled, `1` is Mirostat, and `2` is Mirostat 2.0.
361
376
362
377
`mirostat_tau`: Set the Mirostat target entropy, parameter tau. Default: `5.0`
0 commit comments