explicitly clamp `min_target` and `max_target` to `[0.0, 1.0]`
This commit is contained in:
parent
88fb0f3f32
commit
374bfd4363
|
|
@ -2334,8 +2334,9 @@ static const char * llama_sampler_power_law_name(const struct llama_sampler * /*
|
||||||
static void llama_sampler_power_law_apply(struct llama_sampler * smpl, llama_token_data_array * cur_p) {
|
static void llama_sampler_power_law_apply(struct llama_sampler * smpl, llama_token_data_array * cur_p) {
|
||||||
auto * ctx = (llama_sampler_power_law *) smpl->ctx;
|
auto * ctx = (llama_sampler_power_law *) smpl->ctx;
|
||||||
|
|
||||||
const float min_target = ctx->target - ctx->target_range;
|
// clamp the target range to [0.0, 1.0]
|
||||||
const float max_target = ctx->target + ctx->target_range;
|
const float min_target = std::max(ctx->target - ctx->target_range, 0.0f);
|
||||||
|
const float max_target = std::min(ctx->target + ctx->target_range, 1.0f);
|
||||||
|
|
||||||
// compute probabilities to get the "original" values
|
// compute probabilities to get the "original" values
|
||||||
llama_sampler_softmax_impl(cur_p, false);
|
llama_sampler_softmax_impl(cur_p, false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue