fix for typical sampler

This commit is contained in:
Concedo 2023-09-01 15:24:00 +08:00
parent 0c3a265187
commit d7fed4732f
2 changed files with 9 additions and 2 deletions

View file

@ -2663,7 +2663,10 @@ void llama_v3_sample_typical(struct llama_v3_context * ctx, llama_v3_token_data_
float entropy = 0.0f;
for (size_t i = 0; i < candidates->size; ++i) {
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
if(candidates->data[i].p>0)
{
entropy += -candidates->data[i].p * logf(candidates->data[i].p);
}
}
// Compute the absolute difference between negative log probability and entropy for each candidate