diff --git a/examples/main/README.md b/examples/main/README.md index 3f84bd853..4c16d5545 100644 --- a/examples/main/README.md +++ b/examples/main/README.md @@ -246,13 +246,13 @@ Example usage: `--mirostat 2 --mirostat-lr 0.05 --mirostat-ent 3.0` - `--xtc-probability N`: Sets the chance for token removal (checked once on sampler start) (default: 0.0). - `--xtc-threshold N`: Sets a minimum probability threshold for tokens to be removed (default: 0.1). -Exclude Top Choices (XTC) is a unique sampler that is designed to remove top tokens from consideration and avoid more obvious and repetitive outputs. With a chance of `xtc-p` it searches for tokens with probabilities of `xtc-threshold` and above, then removes all such tokens except the least probable one. +Exclude Top Choices (XTC) is a unique sampler that is designed to remove top tokens from consideration and avoid more obvious and repetitive outputs. With a chance of `xtc-probability` it searches for tokens with probabilities of `xtc-threshold` and above, then removes all such tokens except the least probable one. By removing top tokens XTC can improve the variety of answers, break writing clichés and inhibit repition, since clichés and repeated phrases are usually more likely to appear. By keeping the last token above the threshold, XTC ensures that the answer is still coherent. XTC is meant to be used for creative tasks, but feel free to experiment with different settings for different models. -Being experimental and unique, XTC is disabled by default. The recommended combination of samplers is Min-P followed by XTC on its default settings: `--sampling-seq mx --min-p 0.02 -xtc-p 0.5`. +Being experimental and unique, XTC is disabled by default. The recommended combination of samplers is Min-P followed by XTC on its default settings: `--sampling-seq mx --min-p 0.02 --xtc-probability 0.5`. -Example usage: `-xtc-p 0.5 -xtc-t 0.1 +Example usage: `--xtc-probability 0.5 --xtc-threshold 0.1 ### Logit Bias diff --git a/src/llama-sampling.cpp b/src/llama-sampling.cpp index 2be5a1b7f..0f1cab8b2 100644 --- a/src/llama-sampling.cpp +++ b/src/llama-sampling.cpp @@ -1095,7 +1095,7 @@ static void llama_sample_xtc_apply(struct llama_sampler * smpl, llama_token_data int pos_last = 0; for (size_t i = 0; i < cur_p->size; ++i) { - if (cur_p->data[i].p - ctx->threshold >= -1e-5) { + if (cur_p->data[i].p >= ctx->threshold) { pos_last = i; } else break; } diff --git a/tests/test-sampling.cpp b/tests/test-sampling.cpp index 0368aca9b..1372bdf13 100644 --- a/tests/test-sampling.cpp +++ b/tests/test-sampling.cpp @@ -333,12 +333,12 @@ int main(void) { test_min_p({0.1f, 0.2f, 0.3f, 0.4f}, {0.4f/0.4f}, 1.00f); printf("XTC should:\n"); - test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.1f}, 0.99f, 0.10f); - test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.2f, 0.1f}, 0.99f, 0.20f); - test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.3f, 0.2f, 0.1f}, 0.99f, 0.30f); + test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.1f}, 0.99f, 0.09f); + test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.2f, 0.1f}, 0.99f, 0.19f); + test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.3f, 0.2f, 0.1f}, 0.99f, 0.29f); printf("XTC should not:\n"); - test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.4f, 0.3f, 0.2f, 0.1f}, 0.99f, 0.40f); + test_xtc({0.4f, 0.3f, 0.2f, 0.1f}, {0.4f, 0.3f, 0.2f, 0.1f}, 0.99f, 0.39f); test_tfs({0.1f, 0.15f, 0.2f, 0.25f, 0.3f}, {0.3f}, 0.25f); test_tfs({0.1f, 0.15f, 0.2f, 0.25f, 0.3f}, {0.3f, 0.25f}, 0.75f);