fix for typical sampler
This commit is contained in:
parent
0c3a265187
commit
d7fed4732f
2 changed files with 9 additions and 2 deletions
|
@ -1234,6 +1234,7 @@ struct llama_model_loader {
|
|||
|
||||
// determine file type based on the number of tensors for each quantization and print meta data
|
||||
// TODO: make optional
|
||||
if(false) //disable this log for now
|
||||
{
|
||||
std::map<enum ggml_type, uint32_t> n_type;
|
||||
|
||||
|
@ -3974,7 +3975,10 @@ void llama_sample_typical(struct llama_context * ctx, llama_token_data_array * c
|
|||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue