File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_
35
35
36
36
result->prev .resize (params.n_prev );
37
37
38
- result->n_considered = 0 ;
38
+ result->n_valid = 0 ;
39
39
40
40
llama_sampling_set_rng_seed (result, params.seed );
41
41
@@ -66,7 +66,7 @@ void llama_sampling_reset(llama_sampling_context * ctx) {
66
66
67
67
std::fill (ctx->prev .begin (), ctx->prev .end (), 0 );
68
68
ctx->cur .clear ();
69
- ctx->n_considered = 0 ;
69
+ ctx->n_valid = 0 ;
70
70
}
71
71
72
72
void llama_sampling_set_rng_seed (struct llama_sampling_context * ctx, uint32_t seed) {
@@ -256,7 +256,7 @@ static llama_token llama_sampling_sample_impl(
256
256
}
257
257
}
258
258
259
- ctx_sampling->n_considered = cur_p.size ;
259
+ ctx_sampling->n_valid = temp == 0 . 0f ? 0 : cur_p.size ;
260
260
261
261
return id;
262
262
}
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ struct llama_sampling_context {
81
81
// TODO: replace with ring-buffer
82
82
std::vector<llama_token> prev;
83
83
std::vector<llama_token_data> cur;
84
- size_t n_considered;
84
+ size_t n_valid; // Number of correct top tokens with correct probabilities.
85
85
86
86
std::mt19937 rng;
87
87
};
Original file line number Diff line number Diff line change @@ -2270,10 +2270,10 @@ struct server_context {
2270
2270
2271
2271
const size_t n_probs = std::min (cur_p.size , (size_t ) slot.sparams .n_probs );
2272
2272
if (n_probs > 0 ) {
2273
- const size_t n_considered = slot.ctx_sampling ->n_considered ;
2273
+ const size_t n_valid = slot.ctx_sampling ->n_valid ;
2274
2274
2275
2275
// Make sure at least n_probs top tokens are at the front of the vector:
2276
- if (slot.sparams .temp == 0 .0f && n_probs > n_considered ) {
2276
+ if (slot.sparams .temp == 0 .0f && n_probs > n_valid ) {
2277
2277
llama_sample_top_k (ctx, &cur_p, n_probs, 0 );
2278
2278
}
2279
2279
@@ -2289,7 +2289,7 @@ struct server_context {
2289
2289
for (size_t i = 0 ; i < n_probs; ++i) {
2290
2290
result.probs .push_back ({
2291
2291
cur_p.data [i].id ,
2292
- i >= n_considered ? 0 .0f : cur_p.data [i].p // Tokens filtered out due to e.g. top_k have 0 probability.
2292
+ i >= n_valid ? 0 .0f : cur_p.data [i].p // Tokens filtered out due to e.g. top_k have 0 probability.
2293
2293
});
2294
2294
}
2295
2295
}
You can’t perform that action at this time.
0 commit comments