Skip to content

Commit 672f5e4

Browse files
committed
XTC: fixed random, removed re-normalization
1 parent caa4f84 commit 672f5e4

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

base/llama-addon.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@ void llama_sample_xtc_addon(struct llama_context * ctx, llama_token_data_array *
4545

4646
const int64_t t_start_sample_us = ggml_time_us();
4747

48-
for (size_t i = 0; i < (candidates->size - 1); ++i) { // let's not penalize the last candidate even if it can be, may help with spaces
48+
for (size_t i = 0; i < candidates->size; ++i) {
4949
if (candidates->data[i].p >= xtc_threshold) {
50-
std::srand(std::time(nullptr));
51-
if (std::rand() <= xtc_probability) {
50+
std::random_device rd;
51+
float chance = (float)(rd()%100)/100;
52+
if (chance <= xtc_probability) {
5253
candidates->data[i].p *= 0;
53-
candidates->sorted = false;
5454
}
5555
}
5656
}
5757

58-
// Re-normalize probabilities if required
59-
if (candidates->sorted == false) llama_sample_softmax(ctx, candidates);
60-
6158
llama_set_time(ctx, t_start_sample_us);
6259
}
6360

0 commit comments

Comments
 (0)